We’ve a LO Calc form with a “Send Email” button that exports the sheet as PDF and sends it by email. The last cell that is filled by users is not part of the PDF unless the user click another random cell. Reformulation: after the users has fill the last cell, he must click anywhere on the sheet to “validate” the newly added value; otherwise it won’t be part of the PDF.
As I’m brand new to Macros, I’m comparing our script to the one from the Wiki. Sadly I can’t figure how the Wiki’ script deals with this problem.
Is there a way to “refresh” the sheet before exporting it ? How could I get this last cell to be part of the exported PDF ?
As reference, here’s the part of the Macro that deals with exportation:
Sub ExportToPDF()
'GET SOME NAMES
Dim oDocument As Object, oSheet As Object, oCell As Object
Dim CIS as String, demandeur as String
oDocument = ThisComponent
oSheet= oDocument.getSheets.getByName("formulaire")
oCell = oSheet.getCellRangeByName("CIS") 'get CIS value
CIS = oCell.getString
oCell = oSheet.getCellRangeByName("DEMANDEUR") 'get DEMANDEUR value
demandeur = oCell.getString
'EXPORT PDF
dim document as object
dim dispatcher as object
'Get temporary user path
Dim ps As Object, tempDir As String
ps = CreateUnoService("com.sun.star.util.PathSettings")
tempDir = ps.Temp
'Set filename
Dim fileName as String
fileName = "lovely name here"
ThisComponent.addActionLock
ThisComponent.LockControllers
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Dim path as String
path =tempDir+"/"+fileName+".pdf"
Open path For Append As #1
Close #1
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = tempDir+"/"+fileName+".pdf"
dispatcher.executeDispatch(document, ".uno:ExportDirectToPDF", "", 0, args1())