Consulting

Results 1 to 5 of 5

Thread: Protect CommandBar Menu Item or Prevent use of VBE Menu during an Excel Session

  1. #1
    VBAX Newbie
    Joined
    Apr 2006
    Posts
    2
    Location

    Question Ques: Protect CommandBar Menu Item or Prevent use of VBE Menu during an Excel Session

    How might I prevent use of a custom CommanBar menu item or prevent users from using VBE to view or modify my code. Worksheet, Workbook, and Chart protection fail to prevent use of or access to VBE during Excel session.
    Last edited by cnirvana; 05-04-2006 at 06:18 PM.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You can protect the VBA code from being viewed.

    In the VBE click Tools | VBA Project Properties | Protection
    Check lock project for viewing and then enter a password.

    If you want to disable a command bar you can use this.

    [VBA]Application.CommandBars("CommandBarNameHere").Enabled = False[/VBA]

    Or

    [VBA]
    Application.CommandBars("CommandBarNameHere").Controls("ControlNameHere").E nabled = False
    [/VBA]

  3. #3
    VBAX Newbie
    Joined
    Apr 2006
    Posts
    2
    Location
    Thanks, just what I needed.

    I never thought to look in Project properties.

    cnirvana

  4. #4
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location
    Someone could reset/customize your toolbar by using the Customize
    dialog (Tools > Customize).
    To stop someone from resetting or customizing a commandbar
    you can use:
    [VBA]
    Application.CommandBars("ToolbarNameHere").Protection = msoBarNoCustomize
    [/VBA]
    to reset:
    [VBA]
    Application.CommandBars("ToolbarNameHere").Protection = msoBarNoProtection
    [/VBA]
    To disallow movement of commandbar use:
    [VBA]Application.CommandBars("ToolbarNameHere").Protection = msoBarNoMove[/VBA]

    Marcster.

  5. #5
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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