Re: symbolleiste
05.03.2003 14:36:17
JueKai
Also, beim öffnen von Excel wird die Symbolleiste erstellt (Workbook_Open)...Sub SymbolleisteErstellen()
' Symbolleiste mit Button erstellen wenn noch nicht vorhanden.
Dim cbrLeiste As CommandBar
Dim ctlButton As CommandBarButton
On Error Resume Next
For Each cbrLeiste In Application.CommandBars
If cbrLeiste.Name = "NAME" Then
cbrLeiste.Delete
End If
Next
Set cbrLeiste = CommandBars.Add("NAME")
If Err.Number <> 0 Then
On Error GoTo 0
Exit Sub
End If
On Error GoTo 0
Set ctlButton = cbrLeiste.Controls.Add(msoControlButton)
With ctlButton
.Style = msoButtonCaption
.Visible = True
.Enabled = True
.Caption = "BUTTONNAME"
.OnAction = "fuFUNKTION oder SUB ()"
.Width = 100
End With
With cbrLeiste
.Visible = True
.Position = msoBarTop
End With
End Sub
Vor dem Schliesen der Anwendung wird die Symbolleiste wieder gelöscht...
Sub fuSymbolleisteLoeschen()
' Wird beim beenden der Anwendung ausgeführt. Löscht die Symbolleiste wieder aus Excel
Dim cbrObjekt As CommandBar
On Error Resume Next
Application.CommandBars("NAME").Delete
On Error GoTo 0
End Sub
Knapp beschrieben, aber funzt..
Tschau --> JueKai <--