Consulting

Results 1 to 8 of 8

Thread: how to hide all menus from excel woorkbook?

  1. #1

    how to hide all menus from excel woorkbook?

    Hi,

    I want to hide all the menus from excel sheet after password proteection. Menus like File, Edit, View, etc.

    How can i do this? Please help me.

    Thanks

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    In my ever so humble opinion, you'll want to think this one through. To be decently effective for more than the casual user... I (again, just my opinion) believe you'll want to look at all shortcut key combos, then all the commandbars, as well as replacing (at min) the menubar, lest the user cannot do anything...

    Does that make any sense?

    Mark

  3. #3
    VBAX Regular JONvdHeyden's Avatar
    Joined
    Mar 2009
    Location
    Hampshire, UK
    Posts
    75
    Location
    Also remember that hiding menu's will affect the entire application, not just that workbook. You will need to carefully code it such that the menu's are restored (and not reset) each time the workbook is closed or deactivated.

    Remmember that users may have customised menus so that I why I mention that reset is not appropriate.

    May I ask, why do you want to hide these?
    Regards,
    Jon von der Heyden (Excel 2003, OS XP Pro)

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by JONvdHeyden
    Remmember that users may have customised menus so that I why I mention that reset is not appropriate.
    Hi Jon :-)

    Wow(!), good point! I don't think I've ever 'violated' that , but I don't know that it would have occurred to me either...

    Mark

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


    Option Explicit

    Private mFormulaBar

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim oCB As CommandBar
    For Each oCB In Application.CommandBars
    oCB.Enabled = True
    Next oCB

    Application.DisplayFormulaBar = mFormulaBar
    End Sub

    Private Sub Workbook_Open()
    Dim oCB As CommandBar
    For Each oCB In Application.CommandBars
    oCB.Enabled = False
    Next oCB

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

  6. #6
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Bob,

    If a moment, wouldn't it be better to stick these in activate/deactivate?

    Quite frankly, if I am missing something, your answer will be helpful, so figured better to ask than stare at the dang screen and wonder...

    My thought is that this way if the user has 2(+) wb's open...

    Thank you much,


    Mark

  7. #7
    Quote Originally Posted by JONvdHeyden
    May I ask, why do you want to hide these?
    I want this to give limited access to the user. User should not be able to save or save as the file or able to do any insert and edit operations.

  8. #8
    VBAX Regular JONvdHeyden's Avatar
    Joined
    Mar 2009
    Location
    Hampshire, UK
    Posts
    75
    Location
    Hello again

    You can probably achieve these restrictions using a combination of worksheet protection and macro. You can lock cells for editing and apply worksheet protection to stop users editing.

    And you can use a macro to prevent a user from saving the workbook:

    [VBA]Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True
    End Sub[/VBA]

    Some sort of combination of this is safer than disabling the toolbars, in my humble opinion.
    Regards,
    Jon von der Heyden (Excel 2003, OS XP Pro)

Posting Permissions

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