(viewtopic.php?f=20&t=75413)
Code: Select all
Dim PrintRangeTmpl(0) as New com.sun.star.table.CellRangeAddress
PrintRangeTmpl(0).Sheet=0
PrintRangeTmpl(0).StartColumn = 0
PrintRangeTmpl(0).EndColumn = 13
PrintRangeTmpl(0).StartRow = 0
PrintRangeTmpl(0).EndRow = 64
oSheets = ThisComponent.Sheets
NumSheets = oSheets.Count
for i = 0 to NumSheets - 1
oSheet = oSheets.getByIndex(i)
oCell = oSheet.getCellrangeByName("A100")
If oCell.String = "1" Then
PrintRangeTmpl(0).Sheet = i
else
oSheet.PrintAreas = Array()
oSheet.isvisible = False
end If
next i
ThisComponent.Print(Array())
But now I'm interested in setting this code to print through a printer emulator called "PDFCreator". This will allow my macro to output the selected data to a PDF.
I've been able to change the printer to PDFCreator through commands like:
Code: Select all
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "Printer"
args9(0).Value = "PDFCreator"
dispatcher.executeDispatch(document, ".uno:Printer", "", 0, args9())
If this workbook was only being used on one printer, it would be a simple matter to change the printer back, but the default printer will be named differently at every location where this workbook will be used. I need some way to change the printer to PDFCreator for this one macro, but then return the printer to whatever system default is defined afterward.
Any help would be greatly appreciated!