Display a custom menu with shortcut

Altiman68

New Member
Joined
Mar 23, 2019
Messages
4
Hello,
I create a custom menu called Marks and I want to access it through a shortcut (for example CTRL+M).
Can anoyne help me with the vba code to display it. I want the same effect as ALT+SPACE BAR for displaying Control Menu
Thanks in advance.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You were able to build a custom Menu. But do not know how to display it??

Show me the script you wrote to build a Custom Menu.

Normally to activate a script with a shortcut key. You choose the Macros from the View Menu Then choose View Macro then choose your Macro Then Choose Options and you will see what to do.

Then from then on to launch the macro just use the shortcut key.
 
Last edited:
Upvote 0
Hello again and thanks for your quick answer.
The code of my menu is the following:

Sub New_menu()
Application.CommandBars("Worksheet Menu Bar").Controls.Add Type:=msoControlPopup, Before:=1
Application.CommandBars("Worksheet Menu Bar").Controls.Item(1).Caption = "&Marks"
Application.CommandBars("Worksheet Menu Bar").Controls.Item(1).Controls.Add Type:=msoControlButton, Before:=1
With Application.CommandBars("Worksheet Menu Bar").Controls.Item(1).Controls.Item(1)
.Caption = "Maths"
.OnAction = "Maths"
End With
Application.CommandBars("Worksheet Menu Bar").Controls.Item(1).Controls.Add Type:=msoControlButton, Before:=2
With Application.CommandBars("Worksheet Menu Bar").Controls.Item(1).Controls.Item(2)
.Caption = "Languaje"
.OnAction = "Languaje"
End With
End Sub

It works fine but I hate the new Excel menu for add-in and I want to show the menu using a key combination (similar to alt + space bar)

Bye
 
Upvote 0
I explained in my previous post how you can do this in my previous post:

But you would need to be like Ctrl +B or like Ctrl shift B

Now I know nothing about Add in's
 
Last edited:
Upvote 0
Just for your information.
When I wanted a way to run scripts without having a lot of Buttons or the need to remember a lot of Shortcut keys.

I built myself a Userform
I open the UserForm with a Shortcut Key

On the UserForm I have One Combobox which is loaded with Macro Names automatically when UserForm is opened.

And I have one button on the UserForm which closes the UserForm.

When the user selects a script name from the UserForm ComboBox the script runs.

I can place the Userform any place I want on the screen where it stays and I can work on my sheet with the UserForm Displayed because I opened the UserForm like this: UserForm1.Show Modeless.

And this UserForm could be installed in your Personal Folder and would then be available for use on any Workbook.

The UserForm with only Two controls can be made very small.
 
Upvote 0
I explained in my previous post how you can do this in my previous post:

But you would need to be like Ctrl +B or like Ctrl shift B

Now I know nothing about Add in's

Thanks for your answer.
I know I can execute a macro with a CTRL+KEY combination. But I want to display my menu with that combination. I am looking for the property of CommandBars("Worksheet Menu Bar") that shows or hides its components.

Thanks!
 
Upvote 0
Hello.
Thanks for your answer.
It is a good idea to use an Userform instead of Menu. It certainly will solve my problem.
However I think that there is a way to display any Excel menu with visual basic code.
Bye.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top