Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

A small problem when adding custom menus and switching to other workbooks.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 25 Jan 2007 17:00 GMT
Hi,

I've created a addin which loads up a skeleton menu which (obv.) can
be used with any workbook. This works fine.

On a particular workbook, each sheet loads (and unloads) its own menu
on the Worksheet_Activate and _Deactivate methods. This works fine
too.

My problem is this... when a particular sheet has its' menu loaded and
I switch to another workbook, the previous sheets' menu is still
loaded, visible and available to run.

Is there any way to remove a submenu when a particular workbook has
lost its' focus? I'd rather not have to code evey other workbook to
remove it - I'm hoping I can keep all the code within the same place.

Many thanks,
Dave
Dave Peterson - 25 Jan 2007 17:21 GMT
Maybe you can tie into the workbook events:

Private Sub Workbook_Activate()
Private Sub Workbook_Deactivate()

(Under ThisWorkbook)

> Hi,
>
[quoted text clipped - 15 lines]
> Many thanks,
> Dave

Signature

Dave Peterson

Dave - 25 Jan 2007 17:31 GMT
Hi Dave,

Thanks for the reply.

If I'm not misunderstanding this - each of my sheets has a Deactivate
event which removes its' menu, but if the sheet is active and the user
simply switches to another workbook on the taskbar, the Deactivate
event doesn't 'kick in'.

Perhaps it's because it is still active in its' own workbook.

I need to detect the fact that the user has changed workbooks.

Ideally, that the user has changed workbooks  and has left a active
sheet in another workbook - something like the worksheet has lost
focus, but keeping all the code within the old sheet so it has
complete control of loading and unloading its' own menu.

Does this make sense?

Regards,
Dave

>Maybe you can tie into the workbook events:
>
[quoted text clipped - 22 lines]
>> Many thanks,
>> Dave
Dave Peterson - 25 Jan 2007 18:10 GMT
I'm guessing that the icons on the taskbar are still workbooks open in the same
instance of excel, right?

Then take a look at the workBOOK_deactivate and workBOOK_activate events.  These
are the events that fire when you're swapping workbooks.

These are different than the worksheet events.

> Hi Dave,
>
[quoted text clipped - 45 lines]
> >> Many thanks,
> >> Dave

Signature

Dave Peterson

Dave - 25 Jan 2007 23:15 GMT
Hi Dave,

Yes you guessed right.

Many thanks,
Dave

>I'm guessing that the icons on the taskbar are still workbooks open in the same
>instance of excel, right?
[quoted text clipped - 53 lines]
>> >> Many thanks,
>> >> Dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.