Consulting

Results 1 to 9 of 9

Thread: Hide / Unhide toolbars for a particular worksheet

  1. #1
    VBAX Mentor
    Joined
    Sep 2007
    Posts
    405
    Location

    Hide / Unhide toolbars for a particular worksheet

    Hi,

    Want to hide all the toolbars except the menubar using coding.... and unhide while closing the excel file.

    Tried some coding..... its working for the all the excel applications. want tis coding to be applicabel only for the particular excel file...

    -Sindhuja

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,049
    Location
    Would you like to show the code you have so far?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Option Explicit

    Public WithEvents App As Application

    Private mFormulaBar

    Private Sub App_WindowDeactivate(ByVal Wb As Workbook, ByVal Wn As Window)
    Dim oCB As CommandBar
    If Wb.Name = "myfile.xls" Then

    For Each oCB In Application.CommandBars
    oCB.Enabled = True
    Next oCB

    Application.DisplayFormulaBar = mFormulaBar
    End If
    End Sub

    Private Sub App_WindowActivate(ByVal Wb As Workbook, ByVal Wn As Window)
    Dim oCB As CommandBar
    If Wb.Name = "myfile.xls" Then

    For Each oCB In Application.CommandBars
    oCB.Enabled = False
    Next oCB

    mFormulaBar = Application.DisplayFormulaBar
    Application.DisplayFormulaBar = False

    End If
    End Sub

    Private Sub Workbook_Open()
    Set App = Application
    End Sub
    [/vba]

    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
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by sindhuja
    Want to hide all the toolbars except the menubar...
    Greetings Sinduja,

    An ever-so-slight tweak to Bob's code:

    [vba]Private Sub App_WindowActivate(ByVal Wb As Workbook, ByVal Wn As Window)
    Dim oCB As CommandBar

    If Wb.Name = "myfile.xls" Then

    For Each oCB In Application.CommandBars
    If Not oCB.Name = "Worksheet Menu Bar" _
    Then oCB.Enabled = False
    Next oCB

    mFormulaBar = Application.DisplayFormulaBar
    Application.DisplayFormulaBar = False

    End If
    End Sub[/vba]

    Hope that helps,

    Mark

  5. #5
    VBAX Mentor
    Joined
    Sep 2007
    Posts
    405
    Location
    Thank you everyone for all your help..
    Its works perfectly.......

    -sindhuja

  6. #6
    VBAX Mentor
    Joined
    Sep 2007
    Posts
    405
    Location

    missing tool bars

    Toolbars and menu bar missing - while opening XL 2003

    Any help please...

  7. #7
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings sindhuja,

    Say, you zipped an empty workbook

    Mark

  8. #8
    VBAX Mentor
    Joined
    Sep 2007
    Posts
    405
    Location
    Hi Mark...

    When I open the excel application its not showing the menu bars and all the custom menus….

    Its for all the excel file I open… don’t know how to proceed further to view all the menus..

    Attachment was the sample excel…

    Any help please...

    -Sindhuja

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Because, as Mark said, your workbook doesn't contain any code, never mind the code we gave you. You have to install the code.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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