Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disabling menu item in Word using VBA

    Does anyone know how to disable the menu item Customize in the View, Toolbars menu. I can disable Tools, Customize menu item but not the View, Toolbars menu item.
    I used the following code and everything should work, but it doesn't. I suspect its a bug, but just wanted to check if anyone had any experiences.

    Set cbPopupViewMenu = CommandBars("Menu bar").FindControl(Type:=msoControlPopup, ID:="30004")
    Set cbPopupToolbarsMenu = cbPopupViewMenu.CommandBar.FindControl(Type:=msoCo ntrolPopup, ID:="30045")
    Set cbbtnCustomizeMenu = cbPopupToolbarsMenu.CommandBar.FindControl(Type:=m soControlButton, ID:="797")

    cbbtnCustomizeMenu.Enabled = False


    Thanks
    Helen

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Disabling menu item in Word using VBA

    Helen,

    Try the following two lines of code:

    <pre>CommandBars("Tools").Controls("Customize...") .Enabled = False
    CommandBars("Toolbar List").Enabled = False</pre>


    I haven't tested this, but remembered having read this in MS Press' MS Office 2000 Visual Basic Programmer's Guide.
    BTW I highly recommend this book, and in particular their discussion of manipulating toolbars and menus via code is the most informative I've been able to find anywhere.

    Hope this helps,
    Gary

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling menu item in Word using VBA

    Gary,

    I tested your code and it works great!
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disabling menu item in Word using VBA

    Gary,

    Was looking for this old thread and found it. I thought there was a way to disable the double-click on the toolbar area (not just the right-click), but these 2 lines of code don't.

    I believe 2002 has application.commandbars.disablecustomize, but do you know of a way to trap the d-click to prevent the customize menu from popping up?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Disabling menu item in Word using VBA

    Kevin,

    Yeesh - now that you prompt the memory, I thought you had posted a solution for that in a subsequent thread. I'll try to look for this tomorrow if nothing turns up in the m-time (I gotta go home now and deal with a possibly worm-infected PC <img src=/S/meltdown.gif border=0 alt=meltdown width=15 height=15>).

    Gary

Posting Permissions

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