Questa macro di openoffice calc, permette l’esportazione di un area di celle che salva nel percorso desiderato in formato PDF. La uso come esportazione delle fatture.

Creo un foglio di openoffice calc per ogni fattura, clicco sul pulsante esporta che mi assegna il numero della fattura all’interno del nome del file, ed il nome dell’intestatario della fattura, nel percorso che desidero.

REM ***** BASIC *****

sub EsportaSelezione
rem ———————————————————————-
rem define variables
dim document as object
dim dispatcher as object
dim index as integer
REM dim indexPoint as integer

rem ———————————————————————-
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)

rem ———————————————————————-
rem save current sheet
oDoc1 = Thiscomponent
oSheet1 = oDoc1.CurrentController.getActiveSheet() ‘ the active sheet
sheetoffset1=oSheet1.Rangeaddress.sheet ‘ uses rangeaddress of whole sheet

rem ———————————————————————-
rem clear all print area
For index = 0 to Ubound(thisComponent.getSheets.getElementNames)

oSheet = ThisComponent.Sheets.getByIndex(index)
ThisComponent.CurrentController.setActiveSheet(oSheet)
document = ThisComponent.CurrentController.Frame
dispatcher.executeDispatch(document, “.uno:DeletePrintArea”, “”, 0,Array())

Next index
rem ———————————————————————-
rem set original sheet

ThisComponent.CurrentController.setActiveSheet(oSheet1)
document = ThisComponent.CurrentController.Frame

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = “ToPoint”
args1(0).Value = “C2:Q32”

dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args1())

rem ———————————————————————-
dispatcher.executeDispatch(document, “.uno:DefinePrintArea”, “”, 0, Array())

rem ———————————————————————-
dim args3(2) as new com.sun.star.beans.PropertyValue

dim cella(0) as new com.sun.star.beans.PropertyValue

 

dim varNumFatt as integer
varNumFatt = sheetoffset1 -1
REM MsgBox “In stampa PDF Fattura numero ” + (varNumFatt)
oCell = oSheet1.getCellByPosition(11,4)
pCell = oCell.string
REM MsgBox “Contenuto cella ” + (pCell)

args3(0).Name = “URL”
args3(0).Value = “file:///C:/Users/Ermeglio/Dropbox/Lavoro/Fatturazione/Stampate%20Contabilizzate13/”+ varNumFatt +” – “+ pCell +”.pdf”
args3(1).Name = “FilterName”
args3(1).Value = “calc_pdf_Export”
args3(2).Name = “FilterData”
args3(2).Value = Array(Array(“UseLosslessCompression”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“Quality”,0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ReduceImageResolution”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“MaxImageResolution”,0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“UseTaggedPDF”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SelectPdfVersion”,0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportNotes”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportBookmarks”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“OpenBookmarkLevels”,0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“UseTransitionEffects”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“IsSkipEmptyPages”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“IsAddStream”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“EmbedStandardFonts”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“FormsType”,0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportFormFields”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“AllowDuplicateFieldNames”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“HideViewerToolbar”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“HideViewerMenubar”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“HideViewerWindowControls”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ResizeWindowToInitialPage”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“CenterWindow”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“OpenInFullScreenMode”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“DisplayPDFDocumentTitle”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“InitialView”,0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“Magnification”,0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“Zoom”,0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“PageLayout”,0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“FirstPageOnLeft”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“InitialPage”,0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“Printing”,0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“Changes”,0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“EnableCopyingOfContent”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“EnableTextAccessForAccessibilityTools”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportLinksRelativeFsys”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“PDFViewSelection”,0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ConvertOOoTargetToPDFTarget”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportBookmarksToPDFDestination”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“_OkButtonString”,0,””,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“EncryptFile”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“PreparedPasswords”,0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“RestrictPermissions”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“PreparedPermissionPassword”,0,Array(),com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“”,0,,com.sun.star.beans.PropertyState.DIRECT_VALUE))

dispatcher.executeDispatch(document, “.uno:ExportToPDF”, “”, 0, args3())
end sub