von bitEx33 » Mo, 15.05.2017 14:21
Damit du mich nicht falsch verstehst, erkläre ich es nochmal etwas anders. Als Beispiel habe ich ein Calc-Dokument, das gewisse Daten enthält wie z. B. Projekt, Person, Datum und Zeiten. Diese sind jeweils in den Spalten A(Projekt)
verbinden -->> Spalte B, Spalte C(Person),Spalte D
<<-- verbinden Spalte E(Datum) und Spalte F(Zeiten) aufgeteilt. Damit ich die Formatierung, die ich brauche für die unterschiedlichen Punkte, die ich genannt habe, habe ich eine Makroaufzeichnung gestartet und z. B. bei der Zeile 17 die Formatierung korrekt erstellt. Jetzt ist es aber so, dass das Makro beim Ausführen entsprechend auch nur die Zeile 17 formatiert. Mein Ziel ist es aber meinen Auswahlbereich per Makro zu formatieren. Z. B. wähle ich die Zeile 30 mit Spalte F bis Zeile 43 auch in Spalte F aus und möchte das Makro auf diesen Auswahlbereich anwenden. Ich besitze keine Basic-, VBA-Kenntnisse, nur JavaScript, C# etc.
Hier mein Code:
Code: Alles auswählen
Sub Main
End Sub
sub TineFormatierung
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 = oRange
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Bold"
args2(0).Value = false
dispatcher.executeDispatch(document, ".uno:Bold", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$A$18:$B$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ToggleMergeCells", "", 0, Array())
rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "ToPoint"
args5(0).Value = "$A$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args5())
rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "$A$18:$C$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "VerticalAlignment"
args7(0).Value = 1
dispatcher.executeDispatch(document, ".uno:VerticalAlignment", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "HorizontalAlignment"
args8(0).Value = com.sun.star.table.CellHoriJustify.LEFT
dispatcher.executeDispatch(document, ".uno:HorizontalAlignment", "", 0, args8())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "WrapText"
args9(0).Value = true
dispatcher.executeDispatch(document, ".uno:WrapText", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "ToPoint"
args10(0).Value = "$D$18:$E$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "MoveContents"
args11(0).Value = true
dispatcher.executeDispatch(document, ".uno:ToggleMergeCells", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "ToPoint"
args12(0).Value = "$D$18:$F$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args12())
rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "VerticalAlignment"
args13(0).Value = 1
dispatcher.executeDispatch(document, ".uno:VerticalAlignment", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "HorizontalAlignment"
args14(0).Value = com.sun.star.table.CellHoriJustify.RIGHT
dispatcher.executeDispatch(document, ".uno:HorizontalAlignment", "", 0, args14())
rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "ToPoint"
args15(0).Value = "$D$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args15())
end sub
Damit du mich nicht falsch verstehst, erkläre ich es nochmal etwas anders. Als Beispiel habe ich ein Calc-Dokument, das gewisse Daten enthält wie z. B. Projekt, Person, Datum und Zeiten. Diese sind jeweils in den Spalten A(Projekt) [b][i]verbinden -->>[/i][/b] Spalte B, Spalte C(Person),Spalte D [b][i]<<-- verbinden[/i][/b] Spalte E(Datum) und Spalte F(Zeiten) aufgeteilt. Damit ich die Formatierung, die ich brauche für die unterschiedlichen Punkte, die ich genannt habe, habe ich eine Makroaufzeichnung gestartet und z. B. bei der Zeile 17 die Formatierung korrekt erstellt. Jetzt ist es aber so, dass das Makro beim Ausführen entsprechend auch nur die Zeile 17 formatiert. Mein Ziel ist es aber meinen Auswahlbereich per Makro zu formatieren. Z. B. wähle ich die Zeile 30 mit Spalte F bis Zeile 43 auch in Spalte F aus und möchte das Makro auf diesen Auswahlbereich anwenden. Ich besitze keine Basic-, VBA-Kenntnisse, nur JavaScript, C# etc.
Hier mein Code:
[code]Sub Main
End Sub
sub TineFormatierung
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 = oRange
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Bold"
args2(0).Value = false
dispatcher.executeDispatch(document, ".uno:Bold", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$A$18:$B$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ToggleMergeCells", "", 0, Array())
rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "ToPoint"
args5(0).Value = "$A$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args5())
rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "$A$18:$C$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "VerticalAlignment"
args7(0).Value = 1
dispatcher.executeDispatch(document, ".uno:VerticalAlignment", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "HorizontalAlignment"
args8(0).Value = com.sun.star.table.CellHoriJustify.LEFT
dispatcher.executeDispatch(document, ".uno:HorizontalAlignment", "", 0, args8())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "WrapText"
args9(0).Value = true
dispatcher.executeDispatch(document, ".uno:WrapText", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "ToPoint"
args10(0).Value = "$D$18:$E$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "MoveContents"
args11(0).Value = true
dispatcher.executeDispatch(document, ".uno:ToggleMergeCells", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "ToPoint"
args12(0).Value = "$D$18:$F$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args12())
rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "VerticalAlignment"
args13(0).Value = 1
dispatcher.executeDispatch(document, ".uno:VerticalAlignment", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "HorizontalAlignment"
args14(0).Value = com.sun.star.table.CellHoriJustify.RIGHT
dispatcher.executeDispatch(document, ".uno:HorizontalAlignment", "", 0, args14())
rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "ToPoint"
args15(0).Value = "$D$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args15())
end sub[/code]