I simply ask for help in understanding LO Basic. I do not wish to explore ‘Monty Python’, or that Indonesian island - just BASIC.
Without studying other peoples’ code snippets it is very difficult to learn the ‘magic’ words etc needed in BASIC to call the various functions in APIs. There is a lack of simple code around for the print spreadsheet macros.
I have taken this macro code from the LO Basic guide. ‘Foo.ods’ is a simple workbook containing two sheets, ‘Sheet1’ and ‘Sheet2’. Unfortunately the code only seems to print the sheet on which the Foo.ods was last saved as far as I can see, so sometimes I get Sheet1 and sometimes Sheet2. Print areas are set on both sheets.
Public Doc2
Public oDoc
Sub Main
Dim Url
Dim arg() As New com.sun.star.beans.PropertyValue
Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
DialogLibraries.loadLibrary("Standard")
Url = convertToUrl("C:\foo.ods")
Doc2 = starDeskTop.loadComponentFromUrl (Url, "__blank", 0, arg())
'oDoc = Doc2.Sheets.getByName("Sheet1") OR
'oDoc = Doc2.Sheets(1)
Printit()
End Sub
sub Printit()
Dim PrintProperties(1) As New com.sun.star.beans.PropertyValue
PrintProperties(0).Name="Pages"
PrintProperties(0).Value="1-2"
PrintProperties(1).Name="Wait"
PrintProperties(1).Value=True
Doc2.print(PrintProperties())
end sub
If I replace Doc2 with oDoc I get 'Property or method not found: ‘print’. So, how do I print a selected sheet/s in a workbook with a simple piece of LO Basic code? Just being able to open the LO ‘Print’ screen would be a start!