2008-11-04 3 views

ответ

3

Для того, чтобы панель инструментов, в событии загрузки, вы собираетесь сделать что-то вроде:

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 

Вежливый, что нужно сделать, это удалить панель инструментов на выходе, а также.

+0

@ BradC - там есть интересное имя переменной. :-) – 2008-11-04 16:24:29

1

Не уверен, если это то, что вы ищете, но я думал, что это может помочь вам:

Excel -- Macro Toolbar

Поскольку вы не указываете версию Excel Я не уверен, если это будет работать для вас или нет, но, возможно, это даст вам хорошую отправную точку.

+0

Спасибо ... Excel 2003, но он должен работать и в 2007 году. – Jason 2008-11-04 16:21:59

Смежные вопросы