Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Trapping an attempt to use a custom menu

I've managed to create a custom menu on the menu toolbar that opens and
closes with a particular workbook. It works just fine. But, I am able to
operate the menu from any open workbook and when a menu item is selected I
get an error...which I should since the menu is intended to only work with
the workbook that created it. How do I prevent the user from trying to open
the menu from outside the intended workbook. I am guessing that need to
get the identification of the workbook and compare it to the identification
of active workbook, e.g. the Activeworkbook.Name property. I'm a little over
my head on this one. Can anyone advise me?

TIA

Steve H


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Trapping an attempt to use a custom menu

Hi Steve

The workbook with the code is ThisWorkbook. The active workbook is ActiveWorkbook. So, a
thing like, say
If ThisWorkbook.Name < ActiveWorkbook.Name then Exit Sub
should catch most unwanted calls.
However, you application would probably be more elegant by hiding/howing the menu in the
Workbook_Activate / Deactivate events. Then there's no menu except where it makes sense.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

wrote in message ...
I've managed to create a custom menu on the menu toolbar that opens and
closes with a particular workbook. It works just fine. But, I am able to
operate the menu from any open workbook and when a menu item is selected I
get an error...which I should since the menu is intended to only work with
the workbook that created it. How do I prevent the user from trying to open
the menu from outside the intended workbook. I am guessing that need to
get the identification of the workbook and compare it to the identification
of active workbook, e.g. the Activeworkbook.Name property. I'm a little over
my head on this one. Can anyone advise me?

TIA

Steve H




  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Trapping an attempt to use a custom menu

Harald,

That worked great. I inserted the line before the Call statement in each Sub
called by the .OnAction in the menu selections. Now the menu opens but
closes on any selection.

Thanks

Steve


"Harald Staff" wrote in message
...
Hi Steve

The workbook with the code is ThisWorkbook. The active workbook is

ActiveWorkbook. So, a
thing like, say
If ThisWorkbook.Name < ActiveWorkbook.Name then Exit Sub
should catch most unwanted calls.
However, you application would probably be more elegant by hiding/howing

the menu in the
Workbook_Activate / Deactivate events. Then there's no menu except where

it makes sense.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

wrote in message

...
I've managed to create a custom menu on the menu toolbar that opens and
closes with a particular workbook. It works just fine. But, I am able to
operate the menu from any open workbook and when a menu item is selected

I
get an error...which I should since the menu is intended to only work

with
the workbook that created it. How do I prevent the user from trying to

open
the menu from outside the intended workbook. I am guessing that need

to
get the identification of the workbook and compare it to the

identification
of active workbook, e.g. the Activeworkbook.Name property. I'm a little

over
my head on this one. Can anyone advise me?

TIA

Steve H






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Trapping an attempt to use a custom menu

Glad to hear that Steve. Cheers.

Best wishes Harald
Followup to newsgroup only please.

wrote in message ...
Harald,

That worked great.



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 (not tool bar) TJM Excel Discussion (Misc queries) 1 April 2nd 09 04:43 PM
Custom Menu for 2007 Mike[_14_] Excel Worksheet Functions 1 December 6th 08 04:03 PM
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
Custom menu Alan M Excel Worksheet Functions 4 September 18th 05 11:57 PM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"