Consulting

Results 1 to 2 of 2

Thread: Reinstate User Toolbars Problem

  1. #1
    VBAX Newbie
    Joined
    Jan 2006
    Posts
    5
    Location

    Reinstate User Toolbars Problem

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by SedM
    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
    If 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.

    [vba]
    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
    [/vba]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •