von SIRE.de » Mo, 09.08.2010 17:17
Sorry das Glaskugelproblem ....
Code: Alles auswählen
REM ***** BASIC *****
public bgid as string
public etid as string
Sub Main
' Zugriff auf die Datei
oDok = ThisComponent
' Zugriff auf Rahmen
oFrame = oDok.CurrentController.Frame
' Zugriff auf Blatt
oBlatt = oDok.Sheets().getByName( "IIS" )
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
bgid = oBlatt.getCellByPosition(1,12).string
etid = oBlatt.getCellByPosition(10,12).string
' Zugriff auf Zieldatei
sPfad = "C:/IIS/IIS_Daten.ods"
sUrl = ConvertToUrl( sPfad )
oDokZiel = StarDesktop.loadComponentFromUrl( sUrl, "_blank", 0, Array() )
dim oDokZielFrame as object
oDokZielFrame = oDokZiel.CurrentController.Frame
oZielBlatt = oDokZiel.Sheets().getByName("IIS 00")
oZielBlatt2 = oDokZiel.Sheets().getByName("IIS 01")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Nr"
args1(0).Value = 3
dispatcher.executeDispatch( oDokZielFrame, ".uno:JumpToTable", "", 0, args1())
' Suchbereich definieren
oBereich = oZielBlatt.getCellRangeByName( "J1:J49999" )
' Suchobjekt
oSuchen = oBereich.createSearchDescriptor()
' gesucht wird...
oSuchen.SearchString = etid
' Suche ausführen und Fund-Adresse besetzen
oGefundenAdresse = oBereich.findFirst( oSuchen ).CellAddress
' Index der Zeile
' print oGefundenAdresse.Row
' Kopieren
sKopierBereich = _
"$A$" & oGefundenAdresse.Row + 1 & ":" & _
"$J$" & oGefundenAdresse.Row + 1
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = sKopierBereich
if etid = "Teile ID" then
oDokZiel.close(0)
else
dispatcher.executeDispatch( oDokZielFrame, ".uno:GoToCell", "", 0, args2() )
dispatcher.executeDispatch( oDokZielFrame, ".uno:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Nr"
args3(0).Value = 4
dispatcher.executeDispatch( oDokZielFrame, ".uno:JumpToTable", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
args4(0).Name = "Sel"
args4(0).Value = false
Poszeile = 1
rem ----------------------------------------------------------------------
dim args100(0) as new com.sun.star.beans.PropertyValue
args100(0).Name = "ToPoint"
args100(0).Value = "$J$1"
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoToCell", "", 0, args100())
if bgid = "Teile ID" then
oDokZiel.close(0)
else
Do Until oZielBlatt2.getcellbyPosition(9,PosZeile).string = bgid
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoDown", "", 0, args4())
Poszeile = Poszeile + 1
loop
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoDown", "", 0, args4())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoDown", "", 0, args4())
rem ----------------------------------------------------------------------
dim args200(1) as new com.sun.star.beans.PropertyValue
args200(0).Name = "By"
args200(0).Value = 1
args200(1).Name = "Sel"
args200(1).Value = false
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(oDokZielFrame, ".uno:InsertRows", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(oDokZielFrame, ".uno:Paste", "", 0, Array())
rem IIS_Daten speichern und schließen
If (oDokZiel.isModified) Then
oDokZiel.store()
End if
oDokZiel.close(0)
end if
end if
End Sub
Aber deine Glaskugel ist wirklich sehr gut.
Werd noch bischen basteln ... aber vom Prinzip ist das ja schon echt kritisch ... wenn ich jetzt Makros anlege wie ein Wilder und dann die EDV updated und ich jedesmal schwitzen muß, ob noch alles geht ...
Sorry das Glaskugelproblem .... :D
[code]REM ***** BASIC *****
public bgid as string
public etid as string
Sub Main
' Zugriff auf die Datei
oDok = ThisComponent
' Zugriff auf Rahmen
oFrame = oDok.CurrentController.Frame
' Zugriff auf Blatt
oBlatt = oDok.Sheets().getByName( "IIS" )
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
bgid = oBlatt.getCellByPosition(1,12).string
etid = oBlatt.getCellByPosition(10,12).string
' Zugriff auf Zieldatei
sPfad = "C:/IIS/IIS_Daten.ods"
sUrl = ConvertToUrl( sPfad )
oDokZiel = StarDesktop.loadComponentFromUrl( sUrl, "_blank", 0, Array() )
dim oDokZielFrame as object
oDokZielFrame = oDokZiel.CurrentController.Frame
oZielBlatt = oDokZiel.Sheets().getByName("IIS 00")
oZielBlatt2 = oDokZiel.Sheets().getByName("IIS 01")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Nr"
args1(0).Value = 3
dispatcher.executeDispatch( oDokZielFrame, ".uno:JumpToTable", "", 0, args1())
' Suchbereich definieren
oBereich = oZielBlatt.getCellRangeByName( "J1:J49999" )
' Suchobjekt
oSuchen = oBereich.createSearchDescriptor()
' gesucht wird...
oSuchen.SearchString = etid
' Suche ausführen und Fund-Adresse besetzen
oGefundenAdresse = oBereich.findFirst( oSuchen ).CellAddress
' Index der Zeile
' print oGefundenAdresse.Row
' Kopieren
sKopierBereich = _
"$A$" & oGefundenAdresse.Row + 1 & ":" & _
"$J$" & oGefundenAdresse.Row + 1
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = sKopierBereich
if etid = "Teile ID" then
oDokZiel.close(0)
else
dispatcher.executeDispatch( oDokZielFrame, ".uno:GoToCell", "", 0, args2() )
dispatcher.executeDispatch( oDokZielFrame, ".uno:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Nr"
args3(0).Value = 4
dispatcher.executeDispatch( oDokZielFrame, ".uno:JumpToTable", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
args4(0).Name = "Sel"
args4(0).Value = false
Poszeile = 1
rem ----------------------------------------------------------------------
dim args100(0) as new com.sun.star.beans.PropertyValue
args100(0).Name = "ToPoint"
args100(0).Value = "$J$1"
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoToCell", "", 0, args100())
if bgid = "Teile ID" then
oDokZiel.close(0)
else
Do Until oZielBlatt2.getcellbyPosition(9,PosZeile).string = bgid
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoDown", "", 0, args4())
Poszeile = Poszeile + 1
loop
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoDown", "", 0, args4())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoDown", "", 0, args4())
rem ----------------------------------------------------------------------
dim args200(1) as new com.sun.star.beans.PropertyValue
args200(0).Name = "By"
args200(0).Value = 1
args200(1).Name = "Sel"
args200(1).Value = false
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
dispatcher.executeDispatch(oDokZielFrame, ".uno:GoLeft", "", 0, args200())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(oDokZielFrame, ".uno:InsertRows", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(oDokZielFrame, ".uno:Paste", "", 0, Array())
rem IIS_Daten speichern und schließen
If (oDokZiel.isModified) Then
oDokZiel.store()
End if
oDokZiel.close(0)
end if
end if
End Sub[/code]
Aber deine Glaskugel ist wirklich sehr gut. :D
Werd noch bischen basteln ... aber vom Prinzip ist das ja schon echt kritisch ... wenn ich jetzt Makros anlege wie ein Wilder und dann die EDV updated und ich jedesmal schwitzen muß, ob noch alles geht ...