#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Menu

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Menu

Sorry, that should have been

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("Formatting").Controls("my Button").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)

"Bob Phillips" wrote in message
...
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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Menu

Thanks for the code. But I am miussing something.
Please bear with me. I am a novice with VBA.

I copies the code as a Sub in a module. In place
of "MyMacro" for .action, I put the user form name. When
I open the workbook I do not see any command button. I
am missing something I am sure. Please help!

Thank you,

-- Dileepan


-----Original Message-----
Sorry, that should have been

Private Sub Workbook_BeforeClose(Cancel As Boolean)

On Error Resume Next
Application.CommandBars("Formatting").Controls

("myButton").Delete
On Error GoTo 0

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar

On Error Resume Next
Application.CommandBars("Formatting").Controls("my

Button").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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Menu

Keep it as myMacro.

And have the myMacro code show that user form:

Option Explicit
sub myMacro()
userform1.show
end sub

And make sure you put Bob's code under the ThisWorkbook module--not in a General
module.




"P. Dileepan" wrote:

Thanks for the code. But I am miussing something.
Please bear with me. I am a novice with VBA.

I copies the code as a Sub in a module. In place
of "MyMacro" for .action, I put the user form name. When
I open the workbook I do not see any command button. I
am missing something I am sure. Please help!

Thank you,

-- Dileepan

-----Original Message-----
Sorry, that should have been

Private Sub Workbook_BeforeClose(Cancel As Boolean)

On Error Resume Next
Application.CommandBars("Formatting").Controls

("myButton").Delete
On Error GoTo 0

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar

On Error Resume Next
Application.CommandBars("Formatting").Controls("my

Button").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


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Menu

Thank you for your patience with me. It works fine now.
The help available in this forum is excellent. I
appreaciate all the folks who helped me.

with best regards,

-- Dileepan

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Menu

And watch the spelling of myButton/my button (without a space vs. with a space).





Bob Phillips wrote:

Sorry, that should have been

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("Formatting").Controls("my Button").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)

"Bob Phillips" wrote in message
...
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




--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Menu

I thought I had fixed that one, oh well. Thanks Dave

Bob

"Dave Peterson" wrote in message
...
And watch the spelling of myButton/my button (without a space vs. with a

space).





Bob Phillips wrote:

Sorry, that should have been

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("Formatting").Controls("my Button").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)

"Bob Phillips" wrote in message
...
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



--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop dwn menu. Formula to count selection frm menu in anoth cell? ggoldber Excel Worksheet Functions 1 June 4th 08 02:21 PM
Excel -My paste menu is not the norm. The menu is different. wduval1715 Setting up and Configuration of Excel 2 November 3rd 07 07:07 PM
filter dropdown menu so 2nd drop menu is customized menugal Excel Worksheet Functions 1 September 4th 07 05:25 PM
Create Dropdown menu without using the Validation on the Data Menu lostinformulas Excel Worksheet Functions 0 July 13th 06 08:47 PM
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM


All times are GMT +1. The time now is 11:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"