Guten Tag,
ich habe folgendes Makro aufgezeichnet:
sub Bolzen
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 = "$A$29"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Nr"
args3(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$C$29"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args4())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "Nr"
args6(0).Value = 5
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "ToPoint"
args7(0).Value = "$B$29"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args7())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "Nr"
args9(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "ToPoint"
args10(0).Value = "$C$40"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args10())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "Nr"
args12(0).Value = 5
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args12())
rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "ToPoint"
args13(0).Value = "$C$29"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args13())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "Nr"
args15(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args15())
rem ----------------------------------------------------------------------
dim args16(0) as new com.sun.star.beans.PropertyValue
args16(0).Name = "ToPoint"
args16(0).Value = "$C$21"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args16())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args18(0) as new com.sun.star.beans.PropertyValue
args18(0).Name = "Nr"
args18(0).Value = 5
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args18())
rem ----------------------------------------------------------------------
dim args19(0) as new com.sun.star.beans.PropertyValue
args19(0).Name = "ToPoint"
args19(0).Value = "$D$27"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args19())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args21(0) as new com.sun.star.beans.PropertyValue
args21(0).Name = "Nr"
args21(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args21())
rem ----------------------------------------------------------------------
dim args22(0) as new com.sun.star.beans.PropertyValue
args22(0).Name = "ToPoint"
args22(0).Value = "$C$45"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args22())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args24(0) as new com.sun.star.beans.PropertyValue
args24(0).Name = "Nr"
args24(0).Value = 5
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args24())
rem ----------------------------------------------------------------------
dim args25(0) as new com.sun.star.beans.PropertyValue
args25(0).Name = "ToPoint"
args25(0).Value = "$D$29"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args25())
rem ----------------------------------------------------------------------
dim args26(0) as new com.sun.star.beans.PropertyValue
args26(0).Name = "Nr"
args26(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args26())
rem ----------------------------------------------------------------------
dim args27(0) as new com.sun.star.beans.PropertyValue
args27(0).Name = "Nr"
args27(0).Value = 5
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args27())
rem ----------------------------------------------------------------------
dim args28(0) as new com.sun.star.beans.PropertyValue
args28(0).Name = "StringName"
args28(0).Value = "='Skruvförband EC5'.E32"
dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args28())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())
end sub
Nun möchte ich dieses Makro quasi als Funktion verwenden. Das so vorhandene Makro bezieht sich nur auf die Endzelle D29 des Blattes "HBT Skruv" und dessen Ausgangswerte links daneben und vertikal. Die Tabelle "HBT Skruv" soll damit "aufgefüllt" werden. Das Makro soll also relative Zellbezüge machen, damit ich das Makro auch auf alle weiteren Zellen anwenden kann. Wie macht man so was?
lorbass hat mir im calc-forum folgendes vorgeschlagen und mich dann hier hin geschickt: =bolzen(<durchmesser>;<dicke_stahlplatte>;<dicke_holz>;<winkel>) , wobei "bolzen" obiges Makro ist und eigentlich als Funktion wirkt. Damit könnte ich die Tabelle auffüllen. Wie würde man so was machen?
Bin ein absoluter Anfänger und froh über jeden Tipp. Besten Dank schon im Voraus!
Simon
Makro als Funktion nützen mit relativen Zellbezügen
Moderator: Moderatoren
Makro als Funktion nützen mit relativen Zellbezügen
- Dateianhänge
-
- Beispiel.ods
- (132.55 KiB) 189-mal heruntergeladen