undo custom popup menu

mweaver

Board Regular
Joined
Jul 28, 2002
Messages
129
Well....
Being new to code..... I am exploring custom menu play and was attempting to use a small routine I found here to add custom menus to cell right click. The code:

Sub SetUpBar()
With Application.CommandBars("Cell")
Set temp = .Controls.Add(msoControlButton)
temp.Caption = "Test1"
temp.OnAction = "Routine1" 'put routine1 in regular module
Set temp = .Controls.Add(msoControlButton)
temp.Caption = "Test2"
temp.OnAction = "Routine2" 'put routine2 in regular module
End With
End Sub

Works extremely well! and.... Since it was set as temp I guess I thought I didn't need to remove this custom work upon close.


Can anyone help with a routine to Delete the custom popup buttons I have managed to add with this code?

any help would be appreciated.


mweaver
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

mweaver

Board Regular
Joined
Jul 28, 2002
Messages
129
Thanks Richie(UK) !!

That has done it!

For me ...Workshetets with custom menus seem to go astray sometimes. Is there A small routine I can store for future foul-ups that can delete all meuns (custom or not) and Replace them with Excel's main three: Worksheet Menu Bar, Standard & Formatting???

This would bring a user back to normal.

Any help is appreciated.

Thanks
mweaver
 

Richie(UK)

MrExcel MVP
Joined
May 17, 2002
Messages
3,329
Hi mweaver,

Have a look at this routine re a "restore standard menus" option on the mouse right-click button. Its saved me a few times.<pre>
Option Explicit
Dim temp

'
Sub SetUpBar()

With Application.CommandBars("Cell")
Set temp = .Controls.Add(msoControlButton)
temp.Caption = "Oh Crap - no menus!"
temp.OnAction = "RestoreMenus"
End With

' To put "Back to normal" use :
'Application.CommandBars("cell").Reset

End Sub
'

' Restore menu bar
'

Sub RestoreMenus()

Application.ScreenUpdating = False

Application.CommandBars("Worksheet Menu Bar").Enabled = True
Application.CommandBars("Worksheet Menu Bar").Visible = True
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True

End Sub
'</pre>

Also, have a look at Dave Hawley's site in the VBA Events section. There's a
useful routine or two for hiding menus (and recording which ones you have hidden so they can be restored later!).

http://www.ozgrid.com/

HTH

EDIT: Bloody [pre]tag catches me out every time!
_________________<font color="blue"> «««<font color="red">¤<font color="blue"><font size=+1>Richie</font><font color="red">¤<font color="blue"> »»»</font>

caffeine_sample.gif
</gif>
This message was edited by Richie(UK) on 2002-09-08 14:34
 

Forum statistics

Threads
1,143,709
Messages
5,720,390
Members
422,282
Latest member
psunith

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
Top