How to identify active Menu Bars

M

Matz

Hi,

I need a sub procedure that identifies all active Menu Bars when opening a
workbook.

- Then store the ID
- disable all found Menus
- active a customized Menu (That works already)

before closing Workbook:
- disable customized Menu (That works already)
- enable alle menus that was active in the beginning

I tried something with .findcontrols but I coudn't get it running.

Thanks!!
 
B

Bob Phillips

Option Explicit

Private mFormulaBar

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

Application.DisplayFormulaBar = mFormulaBar
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
M

Matz

Hey Bob

you are great! Perfect - just copy paste....
Thanks for the sunday highlight in VBA :)
Matz
 
Top