Thread: Menu
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Menu

Hi Dileepan,

here is some code that goes in ThisWorkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)

On Error Resume Next
Application.CommandBars("Formatting").Controls("my Button").Delete
On Error GoTo 0

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar

On Error Resume Next
Application.CommandBars(appMenu).Delete
On Error GoTo 0

Set oCB = Application.CommandBars("Formatting")

With oCB
With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "my Button"
.FaceId = 23
.Style = msoButtonIconAndCaption
.OnAction = "myMacro"
End With
End With


End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"P. Dileepan" wrote in message
...
Hi,

I have a macro with user form. I want this macro to be
available as a add-in. When the user opens this xla file
I want the macro to be available for execution as a button
in the command menu. How can I do this.

Thank you.

-- Dileepan