Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default custom menu cross contamination between open workbooks.

I have several Excel workbooks that have custome menus. The workbooks
are set up so that the menus are generated when the workbooks are opened
and the menus are eliminated with the workbooks are closed. However, if
two workbooks are open at the same time, both sets of menus show on both
workbooks.

Some of the people that work for me end up running WorkbookA macros
(from menu) on WorkbookB, and vice versa. Would adding a test at the
beginning of each WorkbookA macro to make sure the active workbook is
WorkbookA prevent errors? If a Workbook is open but in a background
window or miniturized, is it still an "active workbook?"

Is there any way to prevent workbookA's menus from being visible in
WorkbookB if both are OPEN simultaneously?

The menu generation program was generously created by someone other than
myself, perhaps Joseph Rubin. I'm very much indebted to whoever wrote
the code, because it has made my workbooks a lot easier to use and
modify. The beginning of the code looks like:

Sub CreateMenu()
Dim MenuGen As Worksheet
Dim MenuObject As CommandBarPopup
Dim MenuItem As Object
Dim SubMenuItem As CommandBarButton
Dim Row As Integer
Dim MenuLevel, nextlevel, PositionOrMacro, Caption, Divider, FaceId

' Initialize the row counter
Row = 2
Do Until IsEmpty(MenuGen.Cells(Row, 1))
With MenuGen
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrMacro = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
nextlevel = .Cells(Row + 1, 1)
End With

Thanks WindsurferLA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default custom menu cross contamination between open workbooks.

I would use the Workbook_Activate event, to hide the custom menus, you
don't want shown. Just use an IF, or CASE statement, to hide the menus,
depending on which book is active.



*** Sent via Developersdex http://www.developersdex.com ***
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default custom menu cross contamination between open workbooks.

Hi

2 suggestions:-

1) Use the events below in much the same way as the WorkBook_Open and
Workbook_Close events to delete / create your toolbars.....

Workbook_Activate()
Workbook_Deactivate()
Workbook_WindowActivate(ByVal Wn As Window)
Workbook_WindowDeactivate(ByVal Wn As Window)

2) If your macros have to be executed from a specific workbook, you could
start the code with something like...
If ActiveWorkbook.Name<ThisWorkbook.Name then Exit Sub... etc. etc.

--

XL2003
Regards

William



"windsurferLA" wrote in message
...
I have several Excel workbooks that have custome menus. The workbooks are
set up so that the menus are generated when the workbooks are opened and
the menus are eliminated with the workbooks are closed. However, if two
workbooks are open at the same time, both sets of menus show on both
workbooks.

Some of the people that work for me end up running WorkbookA macros (from
menu) on WorkbookB, and vice versa. Would adding a test at the beginning
of each WorkbookA macro to make sure the active workbook is WorkbookA
prevent errors? If a Workbook is open but in a background window or
miniturized, is it still an "active workbook?"

Is there any way to prevent workbookA's menus from being visible in
WorkbookB if both are OPEN simultaneously?

The menu generation program was generously created by someone other than
myself, perhaps Joseph Rubin. I'm very much indebted to whoever wrote the
code, because it has made my workbooks a lot easier to use and modify.
The beginning of the code looks like:

Sub CreateMenu()
Dim MenuGen As Worksheet
Dim MenuObject As CommandBarPopup
Dim MenuItem As Object
Dim SubMenuItem As CommandBarButton
Dim Row As Integer
Dim MenuLevel, nextlevel, PositionOrMacro, Caption, Divider, FaceId

' Initialize the row counter
Row = 2
Do Until IsEmpty(MenuGen.Cells(Row, 1))
With MenuGen
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrMacro = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
nextlevel = .Cells(Row + 1, 1)
End With

Thanks WindsurferLA




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
Cross referencing two workbooks? Jeffrey[_2_] Excel Worksheet Functions 3 January 19th 09 05:40 PM
calculating the probablity of HBsAg contamination jimbo Excel Worksheet Functions 0 October 7th 07 11:49 AM
CROSS REFERENCE BETWEEN WORKBOOKs Chuckles123[_74_] Excel Programming 3 November 25th 04 12:09 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Autoload custom menu on Workbook Open Johann[_2_] Excel Programming 1 December 30th 03 07:55 AM


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