Frage

Wie kann ich eine Toolbar für Excel unter Verwendung eines XLA-Dokument erstellen?

War es hilfreich?

Lösung

Um eine Symbolleiste zu machen, in dem Onload-Ereignisse, Sie gehen so etwas wie:

Dim myBar As CommandBar, myButt As CommandBarControl 

'Delete the toolbar if it already exists'
On Error Resume Next 
CommandBars("My Toolbar").Delete 
On Error Goto 0

Set myBar = CommandBars.Add(Name:="My Toolbar", _
      Position:=msoBarFloating, Temporary:=True) 
myBar.Visible = True 

 ' Create a button with text on the bar and set some properties.'
Set myButt = ComBar.Controls.Add(Type:=msoControlButton) 
With myButt
    .Caption = "Macro1" 
    .Style = msoButtonCaption 
    .TooltipText = "Run Macro1" 
    .OnAction = "Macro1" 
End With 

 ' Create a button with an image on the bar and set some properties.'
Set myButt = ComBar.Controls.Add(Type:=msoControlButton) 
With myButt  
     'the faceId line will let you choose an icon'
     ' If you choose to use the faceId then the caption is not displayed'
    .FaceId = 1000 
    .Caption = "Icon Button" 
    .TooltipText = "Run Macro2" 
    .OnAction = "Macro2" 
End With 

Das höfliche, was zu tun ist, um die Symbolleiste beim Beenden löscht, auch.

Andere Tipps

Nicht sicher, ob dies ist, was Sie suchen, aber ich dachte, das könnte Ihnen helfen:

Excel - Makro-Toolbar

Da Sie nicht angeben, eine Version von Excel ich bin nicht sicher, ob dies für Sie arbeiten oder nicht, aber vielleicht wird es Ihnen mit einem guten Ausgangspunkt liefern.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top