View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default MAJOR PROBLEM! --- Menu Bars don't unhide?

I developed a similar approach to you in an early application & quickly found
myself to be very unpopular. Users genearlly do not like having functionality
taken away & I found they just refused to use it.
I can't add much more than Jim has already said but I do note that you are
hiding all the toolbars but not returning them to the state the user has set
on their desktop which they equally find just as annoying.

Have a play with following code and see if useful for your application. It
stores all visible commandbars (not worksheet menu bar) which will be
restored when you exit your application.

'place this code in
'Workbook_BeforeClose event

HideBars (xlOff)

'place this code in
'Workbook_Open event

HideBars (xlOn)

'normal code module
Sub HideBars(state)

Static myoldbars As New Collection
Dim mybar

If state = xlOn Then
For Each mybar In Application.CommandBars
If mybar.Type < 1 And mybar.Visible Then
myoldbars.Add mybar
mybar.Visible = False
End If
Next mybar

Else
'restore bars
For Each mybar In myoldbars
mybar.Visible = True
Next

End If
End Sub

Hope useful
--
jb


"dim" wrote:

Hi folks.

I have code in my auto_open macro to hide all the excel toolbars and menu
bars to give a clean dictator program appearance.
I also have included in the auto_close macro the code to re-show these menu
bars. All works fine generally....however...

.....some people have been having problems with Excel 2003 if the program is
not shut-down correctly. When they start up Excel (Not my workbook program)
again, the menu bars are still hidden.

I believed that executing my program, and then exiting it again correctly
would fix this, because the auto_close macro would have the opportunity to
show the menus again, but I've been told it doesn't!

I created a basic workbook file with two buttons, one to show and one to
hide the menus. Using this seemingly works fine to retrieve the menu bars.

I've been having problems replicating this issue with Excel 2002. I've run
my program and ended Excel with the Windows Task Manager, and I've run it and
shut down my system cold with the on/off button, but the toolbars are always
there when I start back up.

Is there something about Excel 2003 that I'm missing?

Why does the auto_close macro not retrieve the hidden menu bar and toolbars
when the text of the auto_close code is the exact same as that within the
show/hide workbook?

Any advice is much appreciated. Thanks.

The code segments are as follows:

Sub Auto_open()

If Val(Application.Version) < 9 Then
MsgBox " Program Requires Microsoft Excel 2002 or Newer ", vbOKOnly
+ vbExclamation, "ERROR"
ActiveWorkbook.Save
Application.Quit
End If

If Val(Application.Version) = 9 Then
Response = MsgBox("Program Has Not Been Tested Below Microsoft Excel
2002 - Start Anyway? ", vbYesNo + vbQuestion, "ERROR")
End If
If Response = vbNo Then
ActiveWorkbook.Save
Application.Quit
End If

Application.WindowState = xlMaximized
Application.ShowWindowsInTaskbar = False
Application.CommandBars("Worksheet Menu Bar").Enabled = False
Application.IgnoreRemoteRequests = True
Application.EnableCancelKey = xlDisable
With ActiveWindow
Application.Caption = "My Program"
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
.Zoom = 100
End With
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False
End With
Application.AutoRecover.Enabled = False
ActiveWorkbook.EnableAutoRecover = False
Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Forms").Visible = False
Application.CommandBars("Borders").Visible = False
Application.CommandBars("Chart").Visible = False
Application.CommandBars("Control Toolbox").Visible = False
Application.CommandBars("Drawing").Visible = False
Application.CommandBars("Exit Design Mode").Visible = False
Application.CommandBars("External Data").Visible = False
Application.CommandBars("Formula Auditing").Visible = False
Application.CommandBars("Picture").Visible = False
Application.CommandBars("PivotTable").Visible = False
Application.CommandBars("Protection").Visible = False
Application.CommandBars("Reviewing").Visible = False
Application.CommandBars("Text To Speech").Visible = False
Application.CommandBars("Visual Basic").Visible = False
Application.CommandBars("Watch Window").Visible = False
Application.CommandBars("Web").Visible = False
Application.CommandBars("WordArt").Visible = False
End Sub

Sub Auto_close()
'
' Auto_close Macro
' Macro recorded 10/12/2007
'
'
Workbooks("MyProgram").Activate
ActiveWorkbook.Save
Application.ShowWindowsInTaskbar = True
Application.CommandBars("Worksheet Menu Bar").Enabled = True
Application.IgnoreRemoteRequests = False
Application.EnableCancelKey = xlInterrupt
Sheets("Sheet1").Select
With ActiveWindow
.DisplayGridlines = True
.DisplayHeadings = True
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
Application.AutoRecover.Enabled = True
ActiveWorkbook.EnableAutoRecover = True
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True
Application.Caption = Empty
Application.WindowState = xlNormal
Application.Quit

End Sub