Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post
    I've used Word 2007 for several months, and I can now say I like it. I do have one "issue": I can't find a way to modify a context menu. In Word 2003, I added the "Paste Special..." command to more than one context menu. I do a lot of copying and pasting, and I like to use "Paste Special...> Unformatted text" to avoid messing up my carefully-crafted outline numbering schemes.

    It seems the people who designed Word 2007 did not see fit to allow the humble user to modify a context menu. Unless I've failed to look in the right place, it appears I'm left to drive my mouse pointer all the way up to the ribbon to expand the Paste menu to click "Paste Special." Please, somebody—tell me I've merely overlooked the obvious! Tell me the answer is staring me right in the face! I've searched Word's Help menu; I've searched in this forum; I've searched on the Microsoft Office support page and found not so much as a hint.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='Caesar3' post='791685' date='01-Sep-2009 10:16']I've used Word 2007 for several months, and I can now say I like it. I do have one "issue": I can't find a way to modify a context menu.[/quote]
    I found in various web posts that you can add or remove items using VBA code. Because the links may not be reliable, I will reproduce two examples here. Whether this is helpful to you depends, of course, on whether you can customize this code to fit your own needs.

    === [Start Edit] ===
    This article by MSMVP Greg Maxey looks like a better starting point: Customize Word2007 Shortcut Menus
    === [/End Edit] ===

    Here's some sample code to put an item on the Text context menu to run the AddBullets macro; it assumes that the AddBullets macro and this AutoExec macro are both in Normal.dotm. The .OnAction property is the one that specifies which macro to run when the menu item is clicked; the .Tag property is just an arbitrary string that can be used as a sort of name for the item.

    The Before parameter of the Controls.Add method is the numeric position where the item will be added.

    [codebox]Sub AutoExec()
    Dim cb As CommandBar
    Dim ctl As CommandBarButton
    On Error GoTo bye

    CustomizationContext = NormalTemplate
    Set cb = CommandBars("Text")
    Set ctl = cb.FindControl(Tag:="AddBullets")
    If ctl Is Nothing Then
    Set ctl = cb.Controls.Add(Type:=msoControlButton, _
    Before:=9, Temporary:=True)

    With ctl
    .Caption = "A&dd bullets"
    .Tag = "AddBullets"
    .OnAction = "AddBullets"
    End With
    End If
    bye:
    End Sub[/codebox]

    If you want to remove the item from the menu, you can do it like this:

    [codebox]Sub RemoveAddBullets()
    Dim cb As CommandBar
    Dim ctl As CommandBarControl
    CustomizationContext = NormalTemplate
    Set cb = CommandBars("Text")

    For Each ctl In cb.Controls
    If ctl.Tag = "AddBullets" Then
    ctl.Delete
    End If
    Next
    End Sub[/codebox]

    A somewhat different approach is given in the article "How to: Customize an Item Context Menu" (Word Developer Help).

    --
    Regards,
    Jay Freedman
    Microsoft Word MVP FAQ: http://word.mvps.org
    Freedman notes in a later post:
    There isn't just one Tables context menu. Here's the list:

    Table Cells
    Table Headings
    Table Lists
    Table Pictures
    Table Text
    Whole Table
    Linked Table
    MitchellVII:
    As a follow-up, you can customize the Shortcut Menus in Word 2007, you just need to use code, but it's not hard. Here is an example of adding a Control to the Shortcut Menu for "Table Text" which changes the Bullets Format of the selected text:

    [codebox]Sub fAddMenu_FormatBullets()
    Dim cb As CommandBar
    Dim ctl As CommandBarControl

    'Add FormatBullets Macro to "Table Text" Shortcut Menu...
    CustomizationContext = NormalTemplate
    Set cb = CommandBars("Table Text")

    For Each ctl In cb.Controls
    If ctl.Tag = "FormatBullets" Then
    ctl.Delete
    End If
    Next

    Set ctl = cb.Controls.Add(Type:=msoControlButton, Temporary:=True)
    With ctl
    .Caption = "Format: Bullet List"
    .Tag = "FormatBullets"
    .OnAction = "FormatBullets"
    .BeginGroup = True
    .FaceId = 12
    End With
    End Sub[/codebox]

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post
    Wow! That's really useful information! Thank you very much! I'll try these ideas when I return from vacation.

Posting Permissions

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