Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Create CommandBar

What VBA coding is needed to create a button on the main menu bar for a
shortcut to macro.

thanks in advance!

Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create CommandBar

Dim oCb As CommandBar
Dim oCtl As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtl.Caption = "myButton"
oCtl.Style = msoButtonCaption
oCtl.OnAction = "myMacro"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
What VBA coding is needed to create a button on the main menu bar for a
shortcut to macro.

thanks in advance!

Mike




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Create CommandBar

Thanks again for the coding.

One other question.

If I were to put this in the Workbook_Open section to have the shortcut
button created when the workbook is opened then what coding would I put in
the Workbook_BeforeClose section to have the button removed?

Mike.


"Bob Phillips" wrote in message
...
Dim oCb As CommandBar
Dim oCtl As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtl.Caption = "myButton"
oCtl.Style = msoButtonCaption
oCtl.OnAction = "myMacro"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
What VBA coding is needed to create a button on the main menu bar for a
shortcut to macro.

thanks in advance!

Mike






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create CommandBar

Application.CommandBars("Worksheet Menu Bar").Controls("myButton").Delete

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
Thanks again for the coding.

One other question.

If I were to put this in the Workbook_Open section to have the shortcut
button created when the workbook is opened then what coding would I put in
the Workbook_BeforeClose section to have the button removed?

Mike.


"Bob Phillips" wrote in message
...
Dim oCb As CommandBar
Dim oCtl As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtl.Caption = "myButton"
oCtl.Style = msoButtonCaption
oCtl.OnAction = "myMacro"
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
What VBA coding is needed to create a button on the main menu bar for a
shortcut to macro.

thanks in advance!

Mike








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
create commandbar / control button using codes tango Excel Programming 0 October 26th 04 01:38 AM
Add-In needs to create CommandBar lucp Excel Programming 8 June 27th 04 01:46 PM
Create CommandBar in xl95 code - possible? jamieuk Excel Programming 5 February 9th 04 02:23 PM
Cannot create transparent XP CommandBar picture jamieuk Excel Programming 0 January 28th 04 05:13 PM
Create new commandbar with call procedure Tonmai Excel Programming 1 September 26th 03 09:00 AM


All times are GMT +1. The time now is 07:56 PM.

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

About Us

"It's about Microsoft Excel"