von Karolus » Mo, 30.10.2006 16:34
Hallo Christian
Probiere mal den folgenden Code aus in Verbindung mit einem Tastaturkürzel.
Das Makro führt nebenbei den Tastendruck '↓' aus, fügt dann eine Zeile ein, wenn eine Zeile weiter unten in Spalte C "Zwischensumme" steht und füllt dann auch gleichzeitig die Formel in Spalte H nach unten aus.
Code: Alles auswählen
sub zeileeinifZwischensumme
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 args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
odoc = thisComponent
mysheet=odoc.currentcontroller.activesheet
Zellaktuell=odoc.getCurrentSelection().getCellAddress()
oRow=Zellaktuell.Row
oColumn=Zellaktuell.column
Zellaktuell=mysheet.getCellByPosition(ocolumn,orow)
oZiel = mySheet.getCellByPosition(2,orow+1)
if oZiel.string = "Zwischensumme" then
myrows=mysheet.getrows
' Und jetzt einfügen: Index und Anzahl.
myrows.insertbyindex(orow+1,1)
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "H"& orow+1 & ":H"& orow+2
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FillDown", "", 0, Array())
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "E"& orow+1
args3(1).Name = "Sel"
args3(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
end if
end sub
Gruß Karo
Hallo Christian
Probiere mal den folgenden Code aus in Verbindung mit einem Tastaturkürzel.
Das Makro führt nebenbei den Tastendruck '↓' aus, fügt dann eine Zeile ein, wenn eine Zeile weiter unten in Spalte C "Zwischensumme" steht und füllt dann auch gleichzeitig die Formel in Spalte H nach unten aus.
[code]sub zeileeinifZwischensumme
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 args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
odoc = thisComponent
mysheet=odoc.currentcontroller.activesheet
Zellaktuell=odoc.getCurrentSelection().getCellAddress()
oRow=Zellaktuell.Row
oColumn=Zellaktuell.column
Zellaktuell=mysheet.getCellByPosition(ocolumn,orow)
oZiel = mySheet.getCellByPosition(2,orow+1)
if oZiel.string = "Zwischensumme" then
myrows=mysheet.getrows
' Und jetzt einfügen: Index und Anzahl.
myrows.insertbyindex(orow+1,1)
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "H"& orow+1 & ":H"& orow+2
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FillDown", "", 0, Array())
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "E"& orow+1
args3(1).Name = "Sel"
args3(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
end if
end sub[/code]
Gruß Karo