Makro
Verfasst: Sa, 05.01.2008 16:54
von nixdorf
Hallo,
ich möchte ein Makro nutzen um ein paar Schritte in einem Calc-Dokument zu automatisieren.
Ich klicke also auf Makro aufzeichnen. Dann Makiere ich die Spalte A, gehe auf Kopieren. Makiere dann Spalte B. Dann auf Inhalte einfügen (ohne Formel). Dann beende ich die Aufzeichnung des Makros und speichere es als Makro1 ab. Jetzt lösche ich die Spalte B und führe das Mako1 aus. es passiert aber nichts.
Was mache ich denn da noch falsch?
Gruß Nixdorf
Re: Makro
Verfasst: Sa, 05.01.2008 17:36
von Toxitom
Hey Nixdorf,
nixdorf hat geschrieben:Was mache ich denn da noch falsch?
Wer soll das denn wissen? Unsere Kristallkugeln sind alle noch "auf Urlaub"
Poste doch bitte mal den aufgezeichneten Makro-Code, dann wissen wir mehr. Es kann allerdings auch sein, dass diese Aktion gar nicht "per Aufzeichnung" funktioniert - aber sehn wir mal.
Also, Code her - dann könne wir Auskunft geben.
Gruss
Thomas
PS: Dein Betreff ist auch nicht gerade aussagekräftig!
Re: Makro
Verfasst: So, 06.01.2008 12:05
von nixdorf
Hallo,
Ich möchte in meinem Makro auch Funktionen wie Standartfilter und Text to Columns anwenden. Ich hoffe das geht.
Hier der Code. Den habe ich über >>Extras>>Macro>>Macros verwalten>>OpenOffice_Basic gefunden.
REM ***** BASIC *****
Sub Main
End Sub
sub d
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 = 2
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 = "$A$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$A$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
end sub
sub dd
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 ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$C$8"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$A$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, Array())
end sub
sub upload
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 ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(5) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Flags"
args2(0).Value = "SDNT"
args2(1).Name = "FormulaCommand"
args2(1).Value = 0
args2(2).Name = "SkipEmptyCells"
args2(2).Value = false
args2(3).Name = "Transpose"
args2(3).Value = false
args2(4).Name = "AsLink"
args2(4).Value = false
args2(5).Name = "MoveMode"
args2(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$B$3"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataFilterStandardFilter", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FilterExecute", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args10(5) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Flags"
args10(0).Value = "SDNT"
args10(1).Name = "FormulaCommand"
args10(1).Value = 0
args10(2).Name = "SkipEmptyCells"
args10(2).Value = false
args10(3).Name = "Transpose"
args10(3).Value = false
args10(4).Name = "AsLink"
args10(4).Value = false
args10(5).Name = "MoveMode"
args10(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "ToPoint"
args11(0).Value = "$H$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "ToPoint"
args12(0).Value = "$H$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args12())
rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "ToPoint"
args13(0).Value = "$G$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "ToPoint"
args14(0).Value = "$G$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args14())
rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "ToPoint"
args15(0).Value = "$G$1:$G$627"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args15())
rem ----------------------------------------------------------------------
dim args16(0) as new com.sun.star.beans.PropertyValue
args16(0).Name = "ToPoint"
args16(0).Value = "$G$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args16())
rem ----------------------------------------------------------------------
dim args17(0) as new com.sun.star.beans.PropertyValue
args17(0).Name = "Nr"
args17(0).Value = 2
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args17())
end sub
sub uploadd
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 = "$H$3"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$G$1:$G$627"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
end sub
sub uploaddd
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 ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(5) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Flags"
args2(0).Value = "SDNT"
args2(1).Name = "FormulaCommand"
args2(1).Value = 0
args2(2).Name = "SkipEmptyCells"
args2(2).Value = false
args2(3).Name = "Transpose"
args2(3).Value = false
args2(4).Name = "AsLink"
args2(4).Value = false
args2(5).Name = "MoveMode"
args2(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args2())
end sub
Gruß NIxdorf
Re: Makro
Verfasst: Di, 08.01.2008 09:34
von nixdorf
Hallo,
hat keiner eine Idee? Oder habe ich einen Falschen Code zum Makro gepostet?
Gruß Nixdorf
Re: Makro
Verfasst: Di, 08.01.2008 10:33
von Toxitom
Hallo Nixdorf,
nixdorf hat geschrieben:hat keiner eine Idee? Oder habe ich einen Falschen Code zum Makro gepostet?
Na ja, du hast jede Menge "Dispatcher-Code" geposted. Der geht - oder geht eben nicht. Nicht alles lässt sich mit dem Makrorecorder aufzeichnen. Und den Dispatcher Code kann man nicht "verbessern".
Da hilft nichts - du wirst wohl programmieren lernen müssen. Vergiss den "Dispatcher-Code" - daraus kann man nichts lernen und ihn auch nicht erweitern. Und dann - fang "behutsam" an (Links zu Infos und Lernmaterial findest du im ersten Thread des Basic-Forums). Setz dir deine Ziele nicht gleich zu hoch, verstehe erst einmal, wie die API (und UNO) funktioniert. Erareite dir kleine Makros - und dann, wenn du verstehst, wie die funktionieren, setze dir deine Ziele.
Und wenn du dann im Code nicht weiterkommst, so poste ihn hier mit deinen Fragen - und du bekommst sicher kompetente Antworten. Aber auch hier gilt: Jeder hier macht das freiwillig - es gibt kein "Recht" auf Antwort - und schon gar nicht in definierten Zeitspannen. Ungeduld ist hier eher kontraproduktiv.
Viele Grüße
Thomas