Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Oct 2008
    Location
    Fairfax, Virginia, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Assigning a Macro to a Toolbar (2003)

    Hi! I'm new here. I need to figure out how to assign a macro to a
    menu and/or a toolbar without using the dialog box. Can anybody help
    me?

    THANKS

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assigning a Macro to a Toolbar (2003)

    Welcome to Woody's Lounge!

    The "normal" way to assign a macro assign a macro to a toolbar button and/or menu item is through the Tools | Customize dialog.
    The only other way I know of is to use VBA code - is that what you're looking for?

  3. #3
    New Lounger
    Join Date
    Oct 2008
    Location
    Fairfax, Virginia, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning a Macro to a Toolbar (2003)

    Yes, I guess I have to use VBA. I tried to figure it out by creating a macro, looking at the code, then assigning it the normal way to the menu. I figured if I then looked at the code, it would have added a couple of lines telling the macro to go to the toolbar, but the code didn't change.

    I have looked in several books, but I can't figure it out.

    THANKS

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assigning a Macro to a Toolbar (2003)

    Here's an example. It adds a button to the Formatting toolbar, sets its caption and assigns the macro "MyMacro" to it.

    Sub AddButton()
    With CommandBars("Formatting").Controls.Add(Type:=msoCo ntrolButton)
    .Caption = "My Own Button"
    .Style = msoButtonIconAndCaption
    .FaceId = 37
    .OnAction = "MyMacro"
    End With
    End Sub

    If you click in a word such as CommandBars, Controls, Add etc. (in the Visual Basic Editor) and press F1, you'll get help for that item.

  5. #5
    New Lounger
    Join Date
    Oct 2008
    Location
    Fairfax, Virginia, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning a Macro to a Toolbar (2003)

    Thank you so much. Looks like I have to learn some Visual Basic.
    What book do you recommend?

    Thanks again!

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assigning a Macro to a Toolbar (2003)

    I don't have any books on Word VBA, so I cannot really recommend something. Hopefully someone else will have a suggestion.

Posting Permissions

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