Below are 2 routines that print a sheet to paper and then to a .pdf file.
After the machine is started in the morning, and then for x number of
transactions, these routines work as expected. At some point however, an
error occurs at the line below that says:
"thisComponent.storeToURL(pdfURL,args())"
When I use the debug window to look at the fields being passes to the
storeToURL, they are as expected. I have no idea why after a while the
storeToURL fails and continues to fail until I reboot the machine.
Getting out of LO does not work. I have to reboot the box to get it
functioning again.
After a reboot, the sheet that was to be printed and turned into a pdf
again works as expected. Other executions work as expected until it
stops working as expected some number of transactions later and I have
no idea why.
Because I have to bounce the box to correct this, I suspect the problem
is in a loaded library that does not unload when LO is closed.
Anyone have any insight? I think this is a real bug.
sub receiptPrint(PrintOnPaper as boolean)
dim printRange(0) as new
com.sun.star.table.CellRangeAddress
dim nullRange() as new
com.sun.star.table.CellRangeAddress
dim printOptions(1) as new
com.sun.star.beans.PropertyValue
dim doc as object
dim sheetReceipt as object
On Error goto errorRoutine
doc = ThisComponent
sheetReceipt=doc.sheets.getByName("Receipt")
printOptions(0).Name="Wait"
printOptions(0).Value=True
printOptions(1).Name="CopyCount"
printOptions(1).Value=1
printRange(0).sheet=sheetReceipt.RangeAddress.Sheet
printRange(0).StartColumn=0
printRange(0).StartRow=0
printRange(0).EndColumn=9
printRange(0).EndRow=getEndRow(sheetReceipt)
thisComponent.sheets(sheetReceipt.RangeAddress.Sheet).setPrintAreas(printRange())
if printOnPaper=True then
thisComponent.Print(printOptions())
end if
On error goto 0
printPDF("receipt")
thisComponent.sheets(sheetReceipt.RangeAddress.Sheet).setPrintAreas(nullRange())
saveSpreadSheet()
exit sub
errorRoutine:
dim message as string
if Err<>0 then
message="Error Number " & Err & " at line " & Erl & chr$(10) &
Error() & chr$(10)
msgbox message,0,"Error Occurred"
endif
end sub ' receiptPrint
sub printPDF(subDir as string)
dim odsURL as string
dim pdfURL as string
dim strArray() as string
dim x as integer
DIM args(0) AS NEW com.sun.star.beans.PropertyValue
'exit sub
odsURL=thisComponent.getURL() ' file:///bill/Desktop/WestEnd.ods
' Need file:///bill/Desktop/.pdf/YYMMDD/subDir/count#.pdf
strArray=split(odsURL,"/")
for x=0 to ubound(strArray)-1
pdfURL=pdfURL & strArray(x) & "/"
next x
pdfURL=pdfURL & ".pdf"
if dir(pdfURL,16)="" then
mkdir pdfURL
end if
pdfURL=pdfURL & "/" & right(year(Date()),2) & right(100 +
month(Date()),2) & right(100 + day(Date()),2)
if dir(pdfURL,16)="" then
mkdir pdfURL
end if
pdfURL=pdfURL & "/" & subDir
if dir(pdfURL,16)="" then
mkdir pdfURL
end if
pdfURL=pdfURL & "/"
x=1
while dir(pdfURL & right(1000 + x,3) & ".pdf",16) <> ""
x=x+1
wend
pdfURL=pdfURL & right(1000 + x,3) & ".pdf"
' Save as PDF
args(0).Name = "FilterName"
args(0).Value = "writer_pdf_Export"
thisComponent.storeToURL(pdfURL,args())
end sub
--
For unsubscribe instructions e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted