worksheet menu bar

D

ditchy

Hello there,
would there be a way to hide the Worksheet Menu Bar for one particular
workbook only, and have a macro button to unhide the Worksheet Menu
Bar after a password is entered,
(and not affect all the other workbooks Worksheet Menu Bars)
thank you for any help or suggestions
Ditchy
 
B

Bob Phillips

You could add it to the workbook_Activate event and unhide it in deactivate

Private Sub Workbook_Activate()
if not fAlwaysShown Then
Application.CommandBars("Worksheet Menu Bar").Enabled = False
End If
End Sub

Private Sub Workbook_Deactivate()
Application.CommandBars("Worksheet Menu Bar").Enabled = True
End Sub

and have the same code to unhide in the button macro, but create a global
variable fAlwaysShown and set that to true when the password is entered..


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
D

ditchy

thank you BoB
I wll put this to good use, your help was much appreciated
regards, Ditchy
 
D

ditchy

Hi BoB
cold you explain to me how I go about adding the workbook_activate
event, and create a global
variable fAlwaysShown and set that to true when the password is
entered..
I am not right up with macros yet, only what I have picked up from this
group.
Thanks for your help
Regards, Ditchy
 
B

Bob Phillips

Hi Ditchy,

Workbook event code goes in the THisWorkbook code module. 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

The gloabl variable should be created in a normal code module, circa

Public fAlwaysShown As Boolean

and then, in you button macro, something like

'your code to get a password
If password_correct Then ' sub with your logiv
fAlwaysShown = True
Application.CommandBars("Worksheet Menu Bar").Enabled = True
End IF


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top