Commandbar und Office- Bibliothek
28.08.2003 18:54:44
Romano
zum Level: VBA eher schlechter als gut!
Ich erstelle mit diesem Code eine Symbolleiste:
Option Explicit
Const CBNAME As String = "OfficeTest"
Sub Commandbar_new()
Dim cb As CommandBar, cbp As CommandBarPopup, cbb As CommandBarButton, c As Byte
Call Cbar_delete
Set cb = CommandBars.Add(Name:=CBNAME)
With cb
Set cbp = .Controls.Add(Type:=msoControlPopup)
With cbp
.Caption = "Test"
.Width = 80
End With
With cbp
For c = 1 To 5
Set cbb = .Controls.Add(Type:=msoControlButton)
With cbb
.Style = msoButtonIconAndCaption
.Caption = "Knopf" & c
.FaceId = c * 10
End With
Next
End With
.Enabled = True
.Visible = True
.Position = msoBarFloating
End With
End Sub
Sub Cbar_delete()
On Error Resume Next
CommandBars(CBNAME).Delete
On Error GoTo 0
End Sub
Nun kommts leider öfter mal vor, dass der Verweis auf die Office-
Bibliothek, warum auch immer, nicht gesetzt ist. Dann kommt es zum
Fehler.
Angemeckert wird dann z.B.: Dim cb As CommandBar
weil das die Office- Bibliothek voraussetzt.
Wie kann ich sicherstellen, dass das auch ohne diese Bibliothek
funktioniert?
Danke für Vorschläge!
Gruß Romano