• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

hide menubar

kalpeshpatel

New Member
my workbook contin 3 worksheet


IN worksheet 1 i create a macro for hide toolbar & menubar when activet sheet 1


my code is below


Sub RemoveToolbars()


On Error Resume Next


With Application


.DisplayFullScreen = True


.CommandBars("Full Screen").Visible = False


.CommandBars("MyToolbar").Enabled = True


.CommandBars("MyToolbar").Visible = True


.CommandBars("Worksheet Menu Bar").Enabled = False


End With


On Error GoTo 0


End Sub


Sub RestoreToolbars()


On Error Resume Next


With Application


.DisplayFullScreen = False


.CommandBars("MyToolbar").Enabled = False


.CommandBars("Worksheet Menu Bar").Enabled = True


End With


On Error GoTo 0


End Sub


Private Sub Worksheet_Activate()

Call RemoveToolbars

Worksheets(1).ScrollArea = "a1:f10"


End Sub


Private Sub Worksheet_Deactivate()

Call RestoreToolbars

End Sub


now my problem is when sheet 1 activet menubar is hide but sheet 1 is activate & close the excel & then after again i open this file the menubar is do not hide but i select sheet 2 & then select sheet 1 then menubar is hide


why
 
Modify the RemoveToolbars macro like this:

[pre]
Code:
Sub RemoveToolbars()
If ActiveSheet.Name <> Me.Name Then Exit Sub
On Error Resume Next

With Application
.DisplayFullScreen = True
.CommandBars("Full Screen").Visible = False
.CommandBars("MyToolbar").Enabled = True
.CommandBars("MyToolbar").Visible = True
.CommandBars("Worksheet Menu Bar").Enabled = False
End With
On Error GoTo 0

End Sub
Then, in the ThisWorkbook module, add these two events. Change the Sheet1 object as appropriate to the correct sheet name.

Private Sub Workbook_Activate()
Call Sheet1.RemoveToolbars
End Sub

Private Sub Workbook_Deactivate()
Call Sheet1.RestoreToolbars
End Sub
[/pre]
 
Hi, kalspeshpatel!

I don't understand your question. What Luke M wrote was that you should change the "Sheet1" part of the "Sheet1.RemoveToolbars" and "Sheet1.RestoreToolbars" to "XXXXX", where "XXXXX" is the name of your worksheet.

Does this help you?

Regards!
 
Back
Top