Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Shortcut Popup Menu?

How can I add my own command to the shortcut popup menu in excel? I've
copied the exsample out of the help file and when I run the macro I get this
error message.
"Invalid procedure call or argument" the code is as follows

Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup, _
Temporary:=True)
newMenu.Caption = "Custom"
Set ctrl1 = newMenu.Controls _
.Add(Type:=msoControlButton, ID:=1)
ctrl1.Caption = "Import"
ctrl1.TooltipText = "Import"
ctrl1.Style = msoButtonCaption

The debuger stops at the "Ser newMenu =" line.
There must be an easy way. I just want to add my macro to the shortcut menu.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Shortcut Popup Menu?

I'm not sure what you was meant by "shortcut popup menu". I assume it is the
shortcut menu when you right-click on the worksheet.

Try the following code. Copy and paste into a module, and run
"add_menu_item". You can use the same method to modify any menu. Just replace
the name of the "cell" menu with your target menu name.

'--------------------------------------
Sub add_menu_item()
With Application.CommandBars("Cell").Controls
With .Add(msoControlButton)
.Caption = "My Item"
.OnAction = "my_macro"
End With
End With
End Sub

Private Sub my_macro()
MsgBox ("Hello")
End Sub
'--------------------------------------

Regards,
Edwin Tam

http://www.vonixx.com


"Ricky S" wrote:

How can I add my own command to the shortcut popup menu in excel? I've
copied the exsample out of the help file and when I run the macro I get this
error message.
"Invalid procedure call or argument" the code is as follows

Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup, _
Temporary:=True)
newMenu.Caption = "Custom"
Set ctrl1 = newMenu.Controls _
.Add(Type:=msoControlButton, ID:=1)
ctrl1.Caption = "Import"
ctrl1.TooltipText = "Import"
ctrl1.Style = msoButtonCaption

The debuger stops at the "Ser newMenu =" line.
There must be an easy way. I just want to add my macro to the shortcut menu.




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
Popup Menu / Shortcut Menu Dale Fye Excel Discussion (Misc queries) 2 October 12th 07 12:57 AM
Disable popup menu helmekki[_47_] Excel Programming 0 October 28th 04 01:32 AM
Popup Menu FuzzyLogic Excel Programming 3 February 18th 04 01:11 PM
I N D E X menu via Tabs Popup Greg[_13_] Excel Programming 0 November 12th 03 04:55 PM
add combo box at popup menu GUS Excel Programming 1 September 25th 03 07:27 AM


All times are GMT +1. The time now is 03:47 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"