Ich habe einen Text markiert und ein Beispiel-Makro
Code: Alles auswählen
sub PropertiesEigenschaften
' 2009-07-09 hfr: siehe auch Properties-Abschnitt in "http://wiki.services.openoffice.org/wiki/DE/Makro_Basic_Tutorial#Eingeben_von_Programm-Code"
' basicLibraries.loadLibrary("Xray") 'wird schon automatisch mit dem Start von Openoffice geladen (meine Einstellungen)
if fnWhichComponent(thisComponent) = "Text" then
oCurSelection = thisComponent.getCurrentSelection()
if oCurSelection.supportsService("com.sun.star.text.TextRanges") then
nCount = oCurSelection.Count
xray.xray oCurSelection.getByIndex(0)
'Warnung: Am Einfügepunkt wird die selbe Aktion zwei mal angewandt -
'das macht in diesem Fall nichts, kann aber durchaus problematisch werden.
for i = 0 to nCount - 1 'Steht i für optionale Mehrfachauswahlen?
oCurSelection.getByIndex(i).setPropertyValue("CharStyleName", "Strong Emphasis")
'NUR in OpenOffice.org Basic könne man die Zuweisung auch abkürzen:
'oCurSelection(i).CharStyleName = "Strong Emphasis"
next
end if
end if
end sub 'PropertiesEigenschaften
In der Sub
Code: Alles auswählen
Sub Xray(ObjX As Variant)
Dim kt As Object, isCompatibilityModeTrue As Boolean
' protect from CompatibilityMode(True) current and future incompatibilities
isCompatibilityModeTrue = True
On Error Resume Next
isCompatibilityModeTrue = testPrivateAccess ' variable testPrivateAccess is in Module Mod2
On Error GoTo 0
if isCompatibilityModeTrue then CompatibilityMode(False)
prepareXray
CreateGetObjFunction("") ' init
if IsRealObject(ObjX, false) then
Set OriginalObj = ObjX
if initXrayDisplay(ObjX, txt0113, true) then
kt = XrDial.getControl("OriginName")
kt.Text = txt0115
On Error Resume Next
kt.Text =OriginalObj.ImplementationName
On Error Goto 0
XrDial.Execute
XrDial.Dispose
end if
end if
' restore initial CompatibilityMode() if needed
if isCompatibilityModeTrue then CompatibilityMode(True)
End Sub
Code: Alles auswählen
if IsRealObject(ObjX, false) then
OpenOffice.org 3.1
BASIC-Laufzeitfehler.
Argument ist nicht optional
(für engl.Volltext- Sucher:
In the "Sub Xray(ObjX As Variant)", the line "if IsRealObject(ObjX, false) then" generated the runtime error "argument is not optional.")
Weiß jemand, was Ursache und Abhilfe sein könnten?

PS: Mein Konfiguration siehe: http://wiki.ubuntuusers.de/Benutzer/Hfr