PDA

View Full Version : Reinstate User Toolbars Problem



SedM
01-17-2006, 03:10 AM
When my workbook runs I want the user toolbars to hide and my custom one to be visible. On deactivate, I have the user setting returned. I used some code (http://support.microsoft.com/?kbid=213487) which "remembers" the original user settings and, on deactivation of my book, it makes them visible again.
All fine. But what would happen if my programme crashed? I presume the user would open Excel to find his toolbars missing!
I would be grateful if someone could tell me if this is the case and if there is any way around it.
Des

Bob Phillips
01-17-2006, 03:39 AM
When my workbook runs I want the user toolbars to hide and my custom one to be visible. On deactivate, I have the user setting returned. I used some code (http://support.microsoft.com/?kbid=213487) which "remembers" the original user settings and, on deactivation of my book, it makes them visible again.
All fine. But what would happen if my programme crashed? I presume the user would open Excel to find his toolbars missing!
I would be grateful if someone could tell me if this is the case and if there is any way around it.
DesIf you use a different approach, shown below, you don't need tgo depend upon an array of toolbar states. You can then add the same deactivate code to Workbook_Open in Personal.xls to ensure the status quo at start-up.


Private mFormulaBar

Private Sub Workbook_Activate()
Dim oCB As CommandBar

'Remove commandbars
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next

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

Private Sub Workbook_Deactivate()
Dim oCB As CommandBar

'Restore commandbars
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next

'RestoreFormulaBar
Application.DisplayFormulaBar = mFormulaBar
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