mit folgendem code will ich eine toolbar erstellen.
Code: Alles auswählen
Option Explicit
Sub ToolbarErzeugen
Dim sToolbar as String, sMyToolbarCmdId as String
Dim oCfgSupplier as Object
Dim aToolbareintrag
Dim oToolBarEinstellung
Dim aToolbarItem
sToolbar = "private:resource/Toolbar/MyToolbar"
sMyToolbarCmdId = "vnd.openoffice.org:MyFunction"
oCfgSupplier = createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
oCfgSupplier=thisComponent.getUIConfigurationManager()
oToolBarEinstellung = oCfgSupplier.createSettings()
oToolBarEinstellung.UIname="MyToolbar"
aToolbareintrag = ToolbareintragErstellen("macro:///Standard.Module1.Test()","Test")
oToolBarEinstellung.insertByIndex(0, aToolbarItem ) 'oToolBarEinstellung.insertByIndex(1, aToolbareintrag)
'oToolBarEinstellung.insertByIndex(2, aToolbareintrag)
if oCfgSupplier.hasSettings(sToolbar) then
oCfgSupplier.replaceSettings(sToolbar,oToolBarEinstellung)
else
oCfgSupplier.insertSettings(sToolbar,oToolBarEinstellung)
end if
end Sub
Function ToolbareintragErstellen (Command as String, Label as String) as Variant
Dim aToolbareintrag(2)as New com.sun.star.beans.PropertyValue
aToolbareintrag(0).Name ="CommandURL"
aToolbareintrag(0).Value ="Command"
aToolbareintrag(1).Name ="Label"
aToolbareintrag(1).Value ="Label"
aToolbareintrag(2).Name ="Type"
aToolbareintrag(2).Value="0"
end Function
Sub Test
msgbox("sauberle")
end sub
Code: Alles auswählen
oToolBarEinstellung.insertByIndex(0, aToolbarItem )
basic laufzeitfehler
es ist eine exception aufgetreten
type:com.sun.star.langIllegalArgumentException
message: Type must be com::sun:
com::sun:
weiß jemand rat?
danke
klaus