COMate Excel SaveAs

Share your advanced PureBasic knowledge/code with the community.
spreadz
User
User
Posts: 10
Joined: Sat Feb 11, 2012 1:13 pm
Location: Chesterfield UK
Contact:

COMate Excel SaveAs

Post by spreadz »

In the COMate supplied example, "instantiates an Excel.Application object, adds a new workbook and fills in a few cells "
As a rookie here, how do I save the excel file before quitting?

Code: Select all

XIncludeFile "c:\Program Files\PureBasic\COMatePLUS.pbi"

Define.COMateObject ExcelObject, WorkBook
ExcelObject = COMate_CreateObject("Excel.Application")

If ExcelObject
    If ExcelObject\SetProperty("Visible = #True") = #S_OK
        WorkBook = ExcelObject\GetObjectProperty("Workbooks\Add")
            If WorkBook
                ExcelObject\SetProperty("Cells(1,1) = 'Hello'")
                ExcelObject\SetProperty("Cells(1,2) = 'from'")
                ExcelObject\SetProperty("Cells(1,3) = 'COMate!'")
                ExcelObject\SaveAs('C:\scrapbook\Testing.xls') 
                ExcelObject\Invoke("Quit()") 
                WorkBook\Release()
        EndIf
    EndIf
    ExcelObject\Release()
Else
    MessageRequester("COMate -Excel demo", "Couldn't create the application object!")
EndIf
Inserting . . .
ExcelObject\SaveAs('C:\scrapbook\Testing.xls')
. . . as I have done here, clearly isn't the way to do it!
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMate Excel SaveAs

Post by srod »

Think you might be in the wrong forum section here!

Anyhow, try :

Code: Select all

Workbook\Invoke("SaveAs('C:\scrapbook\Testing.xls')") 
I may look like a mule, but I'm not a complete ass.
spreadz
User
User
Posts: 10
Joined: Sat Feb 11, 2012 1:13 pm
Location: Chesterfield UK
Contact:

Re: COMate Excel SaveAs

Post by spreadz »

Thant's what I needed, thanks.
. . . and sorry for screwing up with my choice of forum topic.
Post Reply