Datenpilot per Makro aufrufen

Das Tabellenkalkulationsprogramm

Moderator: Moderatoren

Bernhard
****
Beiträge: 182
Registriert: Do, 10.08.2006 12:04
Wohnort: Nürnberg

Datenpilot per Makro aufrufen

Beitrag von Bernhard »

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????
Bernhard
------------------
OO-Forum :arrow: das beste was das Web zu bieten hat...
Gert Seler
*******
Beiträge: 1763
Registriert: Di, 03.10.2006 18:05

Re: Datenpilot per Makro aufrufen

Beitrag von Gert Seler »

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

mfg
Gert
Es gibt nichts gutes, außer man tut es.
Win7_64 / LO_4.4.5.2
Charly
*****
Beiträge: 450
Registriert: Di, 20.01.2004 13:14
Wohnort: München

Re: Datenpilot per Makro aufrufen

Beitrag von Charly »

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
Bernhard
****
Beiträge: 182
Registriert: Do, 10.08.2006 12:04
Wohnort: Nürnberg

Re: Datenpilot per Makro aufrufen

Beitrag von Bernhard »

Hallo Charly

das ist wirklich super .. klappt hervorragend!! HERZLICHEN DANK!!!
Bernhard
------------------
OO-Forum :arrow: das beste was das Web zu bieten hat...
Antworten