Datenpilot per Makro aufrufen

Antwort erstellen


BBCode ist eingeschaltet
[img] ist ausgeschaltet
[url] ist eingeschaltet
Smileys sind ausgeschaltet

Die letzten Beiträge des Themas
   

Ansicht erweitern Die letzten Beiträge des Themas: Datenpilot per Makro aufrufen

Re: Datenpilot per Makro aufrufen

von Bernhard » Mi, 11.03.2009 08:30

Hallo Charly

das ist wirklich super .. klappt hervorragend!! HERZLICHEN DANK!!!

Re: Datenpilot per Makro aufrufen

von Charly » Di, 10.03.2009 14:14

Hallo Bernhard!

Der Datenpilot lässt sich nicht aufzeichnen. Er muss mit normalem Starbasic programmiert werden. Ohne deine Tabelle genau zu kennen, habe ich mal versucht, deine Angaben umzusetzen.

Code: Alles auswählen

Sub Datenpilot()

Dok = ThisComponent
Blatt = Dok.sheets.getByName("Tabelle3")
Bereich = Blatt.getCellRangeByName("A5:D1000")

If Dok.sheets.hasByName("Ausgabe") then
Dok.sheets.removeByName("Ausgabe")
end if
Dok.sheets.insertNewByName("Ausgabe",3)
ZielZelle = Dok.sheets.getByName("Ausgabe").getCellRangeByName("A1")
Ziel = ZielZelle.getCellAddress

PilotTab = Blatt.getDataPilotTables()
PilotDesc = PilotTab.createDataPilotDescriptor()
Add = Bereich.getRangeAddress()
PilotDesc.setSourceRange(Add)

PilotFelder = PilotDesc.getDataPilotFields()

PilotFeld = PilotFelder.getByIndex(0)
PilotFeld.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.ROW

PilotFeld = PilotFelder.getByIndex(1)
PilotFeld.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.ROW

PilotFeld = PilotFelder.getByIndex(2)
PilotFeld.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.ROW

PilotFeld = PilotFelder.getByIndex(3)
PilotFeld.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.PAGE

PilotTab.insertNewByName("DP",Ziel,PilotDesc)

End Sub
Gruß
Charly

Re: Datenpilot per Makro aufrufen

von Gert Seler » Di, 10.03.2009 13:54

Hallo Bernhard,
stell die Frage doch mal ins "Forum" "Ooo_Basic/Java" die Basic-Spezies haben das schneller raus.

mfg
Gert

Datenpilot per Makro aufrufen

von Bernhard » Di, 10.03.2009 11:23

Hallo, ich habe das Problem das ich einen Datenpilot per Makro aufrufen will, ich habe auch versucht das ganze mal aufzuzeichnen, aber irgendwie passiert nix, wenn ich den Makro dann aufrufe.

Die Tabelle hat 5 Blätter

Es muss praktisch folgendes getan werden:
Von Blatt 1 in Blatt 3 wechseln
Bereich von A5 -> D5 bis A1000 -> D1000 Markieren
Datenpilot aufrufen
Quelle= Aktuelle Selektion
Seitenfelder: Ausgabe
Zeilenfelder: Kürzel - Friedhof - ehem. Wohnort (die Felder kommen praktisch aus dem Tabellenblatt 3 bzw. dort sind sie als Überschriften in Zeile 5
Ausgabe: neues Tabellenblatt

FERTIG

Code: Alles auswählen

sub Datenpilot_Ausgabe2
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 = "Nr"
args1(0).Value = 5

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

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$B$10"

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

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataDataPilotRun", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DataPilotExec", "", 0, Array())

rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "ToPoint"
args5(0).Value = "$D$12"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:HideColumn", "", 0, Array())


end sub
Weiss jemand wo es hängt??? bzw. warum er gar nix macht????

Nach oben