von Wolfgang Lampert » Do, 10.06.2004 12:11
Hi,
nachstehend 2 (einfache) Makros, die beide das Gleiche machen:
1. Cursor >> Zelle
2. Zelle >> Schriftart ändern
3. Schriftart = Fett
Das 2. Makro (..By_Uno..) wurde über den Makro Recorder erstellt.
Offensichtlich führen 2 vollkommen unterschiedliche Wege zum Ziel.
Kann mir jemand sagen, welcher Weg der sinnvollere ist (und warum?) ?
sub ZellFormatierung
oDoc = StarDesktop.CurrentComponent.getCurrentController
oCell = oDoc.ActiveSheet.getCellRangeByName("a2") REM Zell(bereich) identifizieren
oDoc.Select(oCell) REM Cursor setzen
oCell.CharFontName = "Andale Sans" REM SchriftArt
oCell.CharWeight = com.sun.star.awt.FontWeight.BOLD REM Schriftstärke
end sub
sub ZellFormatierung_By_UnoService
dim oDoc as Object
dim oDispatcher as object
oDoc = ThisComponent.CurrentController.Frame
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
REM Sprung zur Zelle A1 ---------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1"
oDispatcher.executeDispatch(oDoc, ".uno:GoToCell", "", 0, args1())
REM Schriftart bestimmen --------------------------------------------
dim args2(4) as new com.sun.star.beans.PropertyValue
args2(0).Name = "CharFontName.StyleName"
args2(0).Value = ""
args2(1).Name = "CharFontName.Pitch"
args2(1).Value = 2
args2(2).Name = "CharFontName.CharSet"
args2(2).Value = -1
args2(3).Name = "CharFontName.Family"
args2(3).Value = 5
args2(4).Name = "CharFontName.FamilyName"
args2(4).Value = "Andale Sans"
oDispatcher.executeDispatch(oDoc, ".uno:CharFontName", "", 0, args2())
REM Schriftstärke bestimmen ------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Bold"
args3(0).Value = true
oDispatcher.executeDispatch(oDoc, ".uno:Bold", "", 0, args2())
end sub
Gruss Wolf
Hi,
nachstehend 2 (einfache) Makros, die beide das Gleiche machen:
1. Cursor >> Zelle
2. Zelle >> Schriftart ändern
3. Schriftart = Fett
Das 2. Makro (..By_Uno..) wurde über den Makro Recorder erstellt.
Offensichtlich führen 2 vollkommen unterschiedliche Wege zum Ziel.
Kann mir jemand sagen, welcher Weg der sinnvollere ist (und warum?) ?
[quote][b]sub ZellFormatierung[/b]
oDoc = StarDesktop.CurrentComponent.getCurrentController
oCell = oDoc.ActiveSheet.getCellRangeByName("a2") REM Zell(bereich) identifizieren
oDoc.Select(oCell) REM Cursor setzen
oCell.CharFontName = "Andale Sans" REM SchriftArt
oCell.CharWeight = com.sun.star.awt.FontWeight.BOLD REM Schriftstärke
end sub
[b]sub ZellFormatierung_By_UnoService[/b]
dim oDoc as Object
dim oDispatcher as object
oDoc = ThisComponent.CurrentController.Frame
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
REM Sprung zur Zelle A1 ---------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1"
oDispatcher.executeDispatch(oDoc, ".uno:GoToCell", "", 0, args1())
REM Schriftart bestimmen --------------------------------------------
dim args2(4) as new com.sun.star.beans.PropertyValue
args2(0).Name = "CharFontName.StyleName"
args2(0).Value = ""
args2(1).Name = "CharFontName.Pitch"
args2(1).Value = 2
args2(2).Name = "CharFontName.CharSet"
args2(2).Value = -1
args2(3).Name = "CharFontName.Family"
args2(3).Value = 5
args2(4).Name = "CharFontName.FamilyName"
args2(4).Value = "Andale Sans"
oDispatcher.executeDispatch(oDoc, ".uno:CharFontName", "", 0, args2())
REM Schriftstärke bestimmen ------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Bold"
args3(0).Value = true
oDispatcher.executeDispatch(oDoc, ".uno:Bold", "", 0, args2())
end sub[/quote]
Gruss Wolf