PC Review


Reply
Thread Tools Rate Thread

How to add entries in the Menue bar with VBA code?

 
 
Chip Pearson
Guest
Posts: n/a
 
      25th Jan 2007
Try some code like the following:

Sub CreateMenuAndItem()

Dim MenuBar As Office.CommandBar
Dim TopMenu As Office.CommandBarPopup
Dim MenuItem As Office.CommandBarButton

Set MenuBar = Application.CommandBars.FindControl(ID:=30007).Parent
Set TopMenu = MenuBar.Controls.Add(Type:=msoControlPopup, temporary:=True)
TopMenu.Caption = "&My Menu"
Set MenuItem = TopMenu.Controls.Add(Type:=msoControlButton, temporary:=True)
With MenuItem
.Caption = "&Click Me"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!MacroName"
.Tag = "SOME_TEXT_VALUE_FOR_YOUR_APP"
End With

End Sub

Sub MacroName()
MsgBox "Hello World"
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email on the web site)

"Marcel Marien" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hello,
>
> can anybody tell me how to add a new entry into the main menue bar from
> inside a macro? I tried to use the macro recorder, but it seems that this
> kind of operation can not be recorded.
>
> Marcel
>



 
Reply With Quote
 
 
 
 
Marcel Marien
Guest
Posts: n/a
 
      25th Jan 2007
Hello,

can anybody tell me how to add a new entry into the main menue bar from
inside a macro? I tried to use the macro recorder, but it seems that this
kind of operation can not be recorded.

Marcel


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using DLOOKUP in code entries GD Microsoft Access Form Coding 7 6th Jan 2009 06:15 PM
odd context menue (right-click menue) LJB Windows XP Help 3 16th May 2007 03:56 AM
Disable menue entries (osk.exe) Dietmar_Biss Windows XP Embedded 1 26th Jan 2005 04:03 PM
unique entries code scrabtree Microsoft Excel Programming 4 1st Oct 2004 03:43 AM
Is there a way to remove a menue option (other than macro code)? ajames54 Microsoft Excel Misc 1 22nd Apr 2004 03:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 PM.