Pregunta

¿Cómo creo una barra de herramientas para Excel usando un documento XLA?

¿Fue útil?

Solución

Para hacer una barra de herramientas, en el evento de carga, vas a hacer algo como:

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 

Lo educado es eliminar la barra de herramientas al salir, también.

Otros consejos

No estoy seguro de si esto es lo que estás buscando, pero pensé que podría ayudarte:

Excel - Barra de herramientas de macros

Dado que no especifica una versión de Excel, no estoy seguro de si esto funcionará para usted o no, pero tal vez le brinde un buen punto de partida.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top