Custom Menu question...

KMKfan

Board Regular
Joined
Mar 8, 2004
Messages
106
Minor problem:

I have a spreadsheet with a custom menu. The problem I have is:

1. User opens the file (Base) and the menu is created.
2. User does File-Save As (MyFile1). Custom menu still there.
3. User reopens the "Base" file. The custom menu is deleted and recreated.
4. User closes MyFile1. The custom menu is deleted, but "Base" is still open.

Is there a way to keep the custom menu as long at least one file that contains the createmenu macro is open? Right now, I have a command button on my spreadsheet that restores the menu (runs createmenu macro).

Thanks for the help.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hello, KMKfan,

still looking for an answer ?
coincidence brought me here :)

perhaps you can try to put this in the workbookmodule
Code:
Private Sub Workbook_Activate()
CreateMenu
End Sub

elaborating a bit more...
using a public variable (FLAG) could avoid the code to run unnecessarely

in a "normal" module
Public FLAG As Boolean

in the workbook module
Code:
Private Sub Workbook_Open()
FLAG = True
End Sub
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
FLAG = False
End Sub
Code:
Private Sub Workbook_Activate()
If FLAG = True Then Exit Sub
CreateMenu
End Sub
all untested but should be close

kind regards,
Erik
 

Forum statistics

Threads
1,148,529
Messages
5,747,230
Members
424,070
Latest member
smanni3

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