Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Detect Custom Menu

I've got my vba code creating a custom menu called "mymenu". The code only
loads the menu when certain spreadsheets open containing my criteria.

What I can't figure out is how to detect if "mymenu" has already been loaded
and if it has, don't load it a 2nd time. This happens sometimes because the
user opens up several spreads that contain my special criteria in certain
cells.

Any ideas?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Detect Custom Menu

Hi Scott

One way

On the first line of the macro that create the menu delete your menu firs if it exist

On Error Resume Next
Application.CommandBars("MyCustomMenu").Delete
On Error GoTo 0

Then create your menu



--
Regards Ron de Bruin
http://www.rondebruin.nl



"scott" wrote in message ...
I've got my vba code creating a custom menu called "mymenu". The code only loads the menu when certain spreadsheets open
containing my criteria.

What I can't figure out is how to detect if "mymenu" has already been loaded and if it has, don't load it a 2nd time. This happens
sometimes because the user opens up several spreads that contain my special criteria in certain cells.

Any ideas?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Detect Custom Menu

If I open spreadsheet 1, menu loads. If I close spreadsheet 1, menu remains
if excel is left open. If I re-open same or another spreadsheet needing the
menu, it loads a 2nd instance of the menu.

I'm running all code from an add-in I created. I can't place any code in the
spreadsheets because they are machine created.

I'm now wondering if their is a way for an add-in to detect or fire an event
when a spreadsheet that contains certain criteria is being closed.

Do you have an opinion?


"Ron de Bruin" wrote in message
...
Hi Scott

One way

On the first line of the macro that create the menu delete your menu firs
if it exist

On Error Resume Next
Application.CommandBars("MyCustomMenu").Delete
On Error GoTo 0

Then create your menu



--
Regards Ron de Bruin
http://www.rondebruin.nl



"scott" wrote in message
...
I've got my vba code creating a custom menu called "mymenu". The code
only loads the menu when certain spreadsheets open containing my
criteria.

What I can't figure out is how to detect if "mymenu" has already been
loaded and if it has, don't load it a 2nd time. This happens sometimes
because the user opens up several spreads that contain my special
criteria in certain cells.

Any ideas?





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Detect Custom Menu

I got it fixed, I was over looking the obvious. thanks.


"Ron de Bruin" wrote in message
...
Hi Scott

One way

On the first line of the macro that create the menu delete your menu firs
if it exist

On Error Resume Next
Application.CommandBars("MyCustomMenu").Delete
On Error GoTo 0

Then create your menu



--
Regards Ron de Bruin
http://www.rondebruin.nl



"scott" wrote in message
...
I've got my vba code creating a custom menu called "mymenu". The code
only loads the menu when certain spreadsheets open containing my
criteria.

What I can't figure out is how to detect if "mymenu" has already been
loaded and if it has, don't load it a 2nd time. This happens sometimes
because the user opens up several spreads that contain my special
criteria in certain cells.

Any ideas?





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Detect Custom Menu

One way:

Dim mnMyMenu As CommandBarControl
On Error Resume Next
Set mnMyMenu = CommandBars.FindControl(Tag:="my menu")
On Error GoTo 0
If mnMyMenu Is Nothing Then
With CommandBars(1).Controls
Set mnMyMenu = .Add(Type:=msoControlPopup, _
Befo=.Count, Temporary:=True)
End With
With mnMyMenu
.Caption = "mymenu"
.Tag = "my menu"
'...
End With
End If





In article ,
"scott" wrote:

I've got my vba code creating a custom menu called "mymenu". The code only
loads the menu when certain spreadsheets open containing my criteria.

What I can't figure out is how to detect if "mymenu" has already been loaded
and if it has, don't load it a 2nd time. This happens sometimes because the
user opens up several spreads that contain my special criteria in certain
cells.

Any ideas?

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
custom menu winqan Excel Discussion (Misc queries) 1 February 6th 06 10:51 AM
Custom Menu Help EAB1977 Excel Worksheet Functions 1 November 12th 05 01:02 AM
VBA - Disappearing custom menu and custom toolbar Peter[_50_] Excel Programming 2 December 2nd 04 06:09 PM
Custom Menu return to Excel Menu upon Closing VetcalcReport Excel Programming 2 August 2nd 04 02:59 PM
Custom Menu Bob Phillips[_6_] Excel Programming 0 May 7th 04 04:27 PM


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