Fórum pro uživatele kancelářského balíku OpenOffice | LibreOffice
 

#1 Re: Calc » export daného listu/stránky do pdf/OO pomocí makra » 1. 10. 2009 12:20:46

Zdravím,

pro inspiraci zasílám používané makro pro export do PDF. Pro vlastní potřebu ho chce ještě upravit (minimálně cestu pro uložení "args6(0).Value") . Export provádí u označené oblasti.

makro:

rem ----------------------------------------------------------------------
Sub sExport_PDF ' EXPORT do pdf - ZACATEK
rem ----------------------------------------------------------------------

' ziskani nazvu souboru pro export pdf
dim soubor as string
' toto znamena, ze budeme pracovat s patym sloupcem a druhym radkem (bunka E2),
' ale pretoze se cisluje od nuly, tak je to pozice 4,1
soubor = ThisComponent.getSheets.getByIndex(0).getCellByPosition(4,1).getString()

' EXPORT do pdf
dim args6(3) as new com.sun.star.beans.PropertyValue
    args6(0).Name = "URL"
    args6(0).Value = "file:///"+pathPDF+soubor+".pdf" 'premenna nazvu souboru
    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,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,false,_
    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("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("DocumentOpenPassword",0,"",_
    com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,_
    com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PermissionPassword",0,"",_
    com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("",0,,_
    com.sun.star.beans.PropertyState.DIRECT_VALUE))
    args6(3).Name = "SelectionOnly"
    args6(3).Value = true
    dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args6())
   
rem ----------------------------------------------------------------------
End Sub ' KONEC EXPORT do pdf - KONEC
rem ----------------------------------------------------------------------

#2 Re: Další součásti » Programovanie makier - zaciatocnik » 1. 10. 2009 12:14:22

Zdravím,

před nedávnem jsem také začínal a mohu doporučit nápovědu OpenOffice, kde se dá najít většina potřebných funkcí. Odrazit se dá i přes záznam makra a jeho následnou analýzu.

V počátcích se mi osvědčila metoda vytváření jednotlivých "Sub maker" daných problémů a jejich hromadné volání v "Sub Main".

... na specifické problémy pak doporučuji forum na
http://support.openoffice.org/

Zápatí

Používáme FluxBB