Excel

The code created by the macro excel to runin the program generates error in correspondence with the methods followed by the sign: =
What is the exact syntax in xojo?

Dim excel As New ExcelApplication
Dim book As ExcelWorkbook
Dim sheet As ExcelWorksheet
book = Excel.workbooks.Add
excel.visible=true

'Salva con nome
excel.ActiveWorkbook.SaveAs _
Filename:=“C:\MioFile.xls”, _
FileFormat:=xlNormal,_
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Untitled answer

Joking. Please, try to change the title of this conversation for something with meaning for better results. Go to the top and click on the text “Untitled conversation” and try to rewrite it.

Hi Stefano,

i did something with the Excel Object last week… hope this helps… for me the Filename of the Save command was enough… if you need the other commands like Password or FileFormat (old xls?)

Greetings Björn

#if TargetWin32 then

//Declaration
Dim FilenameSeminar As String

Dim Excel as new ExcelApplication
Dim Book As ExcelWorkbook
Dim Sheet As ExcelWorksheet


//Set Values of Variables
// here you can place your Filename for the SaveMethod
FilenameSeminar="PLACE YOUR FILENAME WITH PATH HERE"


//SetExcelState
excel.Visible = false // Excel is invisible during processing
book = excel.Workbooks.Add

Excel.Application.DisplayAlerts=False // should set Alarm messages off if file exists

// Save Workbook mit Dateiname für das Seminar
book.SaveAs(FilenameSeminar) //

// Save Workbook mit Dateiname die Serienbriefautomation
FilenameExport=mydocsfolder + Folder + FilenameExport + Suffix
book.SaveAs(FilenameExport)


//Quit Excel
'Excel.Visible=True
Excel.Application.DisplayAlerts=True

Excel.Application.Quit
Excel=nil

//Unexpected Error Handling
'Exception err as OLEException
'msgbox err.message

Quit
...

They explained that
In the Save As: = xlNormal should be replaced with the value.
Example: excel.ActiveWorkbook.SaveAs “C: \ xls”, 1 (1 = save in excel format)
This is true always.
You have to replace the parameters “name” with their values

You can think the named parameters in the VBA command as a dictionary (for each name there is a value) if you don’t set a value, it has the default value, you can set them in any order.

In Xojo you don’t have this “dictionary” style, but you have the default values.
So if you want only save with another name you will use:
excel.activeWorkbook.saveAs “file path”

if you want change the format:
excel.activeWorkbook.saveAs “file path”,formatConstant

and so on as a normal Xojo method call