Calc. Esportare gruppi di celle non contigue in PDF

Salve,
ho un problema relativo all’esportazione in PDF.
Vorrei salvare in un unico file PDF due gruppi di celle non contigue, la mia macro attuale è questa:
sub EsportToPDF (byval fileout as string)
dim iDoc as object
dim iSheet as object
dim mFilterData(0) As New com.sun.star.beans.PropertyValue
dim mStoreOpts(2) As New com.sun.star.beans.PropertyValue
iDoc = ThisComponent
iSheet = iDoc.getCurrentController.ActiveSheet
mFilterData(0).Name = “Selection”
mFilterData(0).Value = iSheet.getCellRangeByName("$BB$1:$BU$30")
mStoreOpts(0).Name = “Overwrite”
mStoreOpts(0).Value = True
mStoreOpts(1).Name = “FilterName”
mStoreOpts(1).Value = “calc_pdf_Export”
mStoreOpts(2).Name = “FilterData”
mStoreOpts(2).Value = mFilterData()
ThisComponent.storeToURL(fileout, mStoreOpts())
end sub
che esporta le celle dell’intervallo BB1:BU30.
Come posso modificarla per salvare in un’unico file PDF sia le celle dell’intervallo BB1:BU30 che quelle dell’intervallo CA1:CG50
Grazie

Suggerisco in un nuovo foglio di calcolo di collegare i due gruppi di celle, in modo da poter esportare un’unica area.

Grazie! Purtroppo però le formattazioni delle colonne (larghezza delle colonne) sono completamente diverse e non posso “incolonnare” i due gruppi di celle, ti ringrazio comunque del suggerimento

Eseguire le seguenti operazioni:

Seleziona le celle AA1:AG29
Formato / Intervallo di stampa / Imposta

Seleziona le celle A1:T22
Formato / Intervallo di stampa / Aggiungi

Formato/Stile pagina
in Fogli,
Scala = Riduci l’intervallo di stampa larghezza/altezza
Larghezza = 1
Altezza = 2

1 Like

Grazie alla soluzione di schiavinatto (che ringrazio infinitamente) ecco la macro modificata per creare un file PDF fileout a partire da due intervalli non contigui di celle del foglio corrente
sub EsportToPDF (byval fileout as string)
dim iDoc as object
dim dispatcher as object

iDoc = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = “ToPoint” : args1(0).Value = “$CA$1:$CG$29”
dispatcher.executeDispatch(iDoc, “.uno:GoToCell”, “”, 0, args1())
dispatcher.executeDispatch(iDoc, “.uno:DefinePrintArea”, “”, 0, Array())

dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = “ToPoint” : args3(0).Value = “$BB$1:$BU$” + rigrisf
dispatcher.executeDispatch(iDoc, “.uno:GoToCell”, “”, 0, args3())
dispatcher.executeDispatch(iDoc, “.uno:AddPrintArea”, “”, 0, Array())

dim args6(2) as new com.sun.star.beans.PropertyValue
args6(0).Name = “URL”
args6(0).Value = fileout
args6(1).Name = “FilterName”
args6(1).Value = “calc_pdf_Export”
args6(2).Name = “FilterData”
args6(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,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“MaxImageResolution”,0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“UseTaggedPDF”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SelectPdfVersion”,0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“PDFUACompliance”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportNotes”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ViewPDFAfterExport”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportBookmarks”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SinglePageSheets”,0,false,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(“ExportPlaceholders”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“IsAddStream”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“ExportFormFields”,0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“FormsType”,0,0,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,1,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,true,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(“SignPDF”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“Watermark”,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(“Selection”,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SignatureLocation”,0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SignatureReason”,0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SignatureContactInfo”,0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SignaturePassword”,0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SignatureCertificate”,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“SignatureTSA”,0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array(“UseReferenceXObject”,0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE))
dispatcher.executeDispatch(iDoc, “.uno:ExportToPDF”, “”, 0, args6())

end sub