Ernst_42
schläft auf dem Boardsofa
Hallöchen liebe Programmierer-Experten...
nach Stunden vergeblicher Suche stelle ich mal hier meine Frage.
Hier läuft:
OpenOffice 3.x als NeoOffice/J 3.x
auf Mac OS X 10.6.x
Aufgabenstellung:
Bisher gelöst:
2. und 3. (trivial)
ungelöst:
1.
Problem:
Die Methode StoreToURL scheint nur für das Dokument selbst, nicht aber für einzelne Blätter zu funktionieren. => Es wird das gesamte Dokument als PDF exportiert
Die Methode Print scheint nicht für den PDF-Export geeignet zu sein (wäre über den Dialog aber die Möglichkeit, nur ein einzelnes Blatt zu "drucken").
(Im Code rot markiert.)
Kann mir jemand einen Fingerzeig geben? TIA
Meine Lösung bisher:
nach Stunden vergeblicher Suche stelle ich mal hier meine Frage.
Hier läuft:
OpenOffice 3.x als NeoOffice/J 3.x
auf Mac OS X 10.6.x
Aufgabenstellung:
- Ich möchte in einem Calc-Dokument einzelne(!) Blätter als PDF exportieren.
- Der Ordnername wird einer Zelle entnommen, die das Datum der letzten (automatisierten) Überarbeitung enthält.
- Die Namen der Tabellenblätter werden als Dateinamen übernommen.
Bisher gelöst:
2. und 3. (trivial)
ungelöst:
1.
Problem:
Die Methode StoreToURL scheint nur für das Dokument selbst, nicht aber für einzelne Blätter zu funktionieren. => Es wird das gesamte Dokument als PDF exportiert
Die Methode Print scheint nicht für den PDF-Export geeignet zu sein (wäre über den Dialog aber die Möglichkeit, nur ein einzelnes Blatt zu "drucken").
(Im Code rot markiert.)
Kann mir jemand einen Fingerzeig geben? TIA
Meine Lösung bisher:
Code:
Sub myPDFExport
const ci_Sh_num as integer = 5
dim document as object
dim dispatcher as object
dim i as integer
dim args0(0) as new com.sun.star.beans.PropertyValue
[COLOR="Gray"] rem NICHT ABGEFANGEN WIRD DERZEIT,
rem FALLS DER ENTSPRECHENDER ORDNER NOCH NICHT EXISTIERT !!!
rem get access to the document[/COLOR]
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
[COLOR="Gray"] rem - Hole aktuellen Stand (Datum)[/COLOR]
args0(0).Name = "ToPoint"
args0(0).Value = "Version_Date"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args0())
dim dayFormatted as string
dayFormatted = right(ThisComponent.getCurrentSelection().getstring(),10)
dayFormatted = left(version_date,4) + mid(version_date,6,2) + right(version_date,2)
[COLOR="Gray"] rem - Export PDF - Attributes[/COLOR]
dim pdfProperties(0) as new com.sun.star.beans.PropertyValue
pdfProperties(0).Name = "FilterName"
pdfProperties(0).Value = "calc_pdf_Export"
[COLOR="Gray"] rem - path and extension[/COLOR]
dim path as string
path = "/Users/Shared/Vids/- Contents (2print)/" + dayFormatted
dim extension as string
extension = ".pdf"
[COLOR="Gray"] rem - string containing protocol, path and filename[/COLOR]
dim pdfurl as string
[COLOR="Gray"] rem - sheet's number[/COLOR]
args0(0).Name = "Nr"
[COLOR="Gray"] rem : "args0(0).Value" will be set separately[/COLOR]
for i=1 to ci_Sh_num
args0(0).Value = i
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args0())
pdfurl = converttourl("file:///" + path + "/" + ThisComponent.getCurrentController.getActiveSheet.getName() + extension)
[COLOR="Gray"] rem - Export PDF[/COLOR]
[COLOR="Gray"] rem Variante 1 - Fehler, da Methode nicht verfügbar[/COLOR]
[COLOR="Red"][B] ThisComponent.getCurrentController.getActiveSheet.storeToURL(pdfurl, pdfProperties())[/B][/COLOR]
[COLOR="Gray"] rem Variante 2 - exportiert aber leider alles![/COLOR]
[COLOR="Red"][B] ThisComponent.storeToURL(pdfurl, pdfProperties()) [/B][/COLOR]
next i
End Sub ' Sub myPDFExport