Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to add entries in the Menue bar with VBA code?

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).Par ent
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" wrote in message
...
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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How to add entries in the Menue bar with VBA code?

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
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
vb drop down menue conorot Excel Discussion (Misc queries) 1 May 17th 06 10:03 AM
How do I set up XML on Data menue? Mkitaguchi Excel Discussion (Misc queries) 1 May 2nd 06 09:29 PM
Menue Syed Haider Ali[_18_] Excel Programming 2 September 5th 05 12:21 AM
unique entries code scrabtree[_2_] Excel Programming 4 October 1st 04 03:43 AM
Enforced entries code pjhageman[_10_] Excel Programming 1 January 12th 04 01:30 AM


All times are GMT +1. The time now is 01:08 AM.

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"