Hi all

I have a requirement to generate PDF's from specific set sheets contained in 
one Calc document, the document has 85 individual sheets. 

I've generated a macro to do this, having first recorded the steps using the 
macro recorder. Though the steps to record the macro worked perfectly as only 
the individual selection, i.e, all the cells on a specific sheet, was generated 
as a PDF. If I then run the macro with the same selection it always creates a 
PDF of  the entire document - all 85 sheets instead of just the selection!

Here's the recorded macro, note the selection "$A$1:$G$35" 

sub exporttopdf
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object

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

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1:$G$35"

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

rem ----------------------------------------------------------------------
dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "URL"
args2(0).Value = "file:///home/alex/example.pdf"
args2(1).Name = "FilterName"
args2(1).Value = "calc_pdf_Export"
args2(2).Name = "FilterData"
args2(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("ViewPDFAfterExport",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("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("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",,,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))

dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args2())


end sub

Clearly the recorded macro has failed to record correctly, I do know that this 
can happen from time to time, and that I should tweak something in the above 
array, but don't not what and am finding it difficult to track down where these 
parameters are described in the documentation. Can anyone point me to where 
these parameters are described?

I've managed to derive a workaround for this which is to hide all the sheets 
that I'm not interested in then executing this block of code. It's a bit 
cumbersome as I have to hide 84 sheets just to create a PDF of one sheet. 

Whilst writing this note I've thought of another method that is to print the 
active sheet to a pdf file. I'm busily reading Andrew Pitonyak’s book
OpenOffice.org Macros Explained. Again I need to find the methods and 
properties associated with printin Calc sheets. Again can anyone point me in 
the right direction?

Could this be a question for the Developer's list?

Thanks 

Alex


-- 
To unsubscribe 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

Reply via email to