Macros / Custom Toolbar Help - Word 2007/2010

I have a DOT file that I need to modify  - it was created in Word 2003.  There are 10+ macros assigned to the custom toolbar.  

I need to know how, in Word 2010 (or 2007, which I also have) I can do the following:
a) find out which macro is assigned to a specific icon on the toolbar; and
b) create / copy it to a different template (which also has to be in "DOT" (not DOTM/DOTX) format.

I've looked at a ton of reference materials but am not finding this.  

The DOT needs to work in 2003.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

GrahamSkanConnect With a Mentor RetiredCommented:
This code will list all the buttons which run macros. It was designed in Word 2003
Sub ListButtons()
    Dim bar As CommandBar
    Dim but As CommandBarControl
    Dim tbl As Table
    Dim rw As Row
    Dim rng As Range
    Set tbl = ActiveDocument.Tables.Add(ActiveDocument.Bookmarks("\EndOfDoc").Range, 1, 4)
    tbl.Cell(1, 1).Range.Text = "Toolbar"
    tbl.Cell(1, 2).Range.Text = "Button"
    tbl.Cell(1, 3).Range.Text = "On Action"
    tbl.Cell(1, 4).Range.Text = "Icon"
    For Each bar In CommandBars
        For Each but In bar.Controls
            If but.Type = msoControlButton Then
                If Len(but.OnAction) > 0 Then
                    Set rw = tbl.Rows.Add
                    rw.Cells(1).Range.Text = bar.Name
                    rw.Cells(2).Range.Text = but.Caption
                    rw.Cells(3).Range.Text = but.OnAction
                    Set rng = rw.Cells(4).Range
                    rng.Collapse wdCollapseStart
                End If
            End If
        Next but
    Next bar
End Sub

Open in new window

PandaPantsConnect With a Mentor Commented:
I have neither Word 2010 nor 2007, but I can give you something that will likely work, if you want to take the time:
Since you have access to the template, open it up to where you can see the code, then put a break point at the beginning of each macro or function. Return to the Word window and run the first macro on the toolbar; the code should stop immediately at one of the break points you assigned. Make a note, and move on to the next one.

If there are many more macros in the template than on the toolbar, there will be a lot of prep involved, but it will work eventually. (Unless, of course, some of the toolbar icons refer to macros in other templates that are assumed to be available...but we don't have to go there right away.) Good luck.
Sorry, I forgot to address your second question, regarding sharing. For that, use the 2010 equivalent (I'm assuming there is one) of the Organizer tool to copy the code modules from one template to another.

If you want to copy *only* the 10 or so macros that are directly called from the toolbar, and they're not already all in the same module, you can either (a) create a new module and copy those macros to that new module with the copy-and-paste method, or (b) copy all the modules to the new template and then delete those macros that you don't need.

A word of caution, probably not needed: It's possible--even likely--that the macro called by the toolbar icon actually chains to other macros that aren't directly referenced from the toolbar, and those macros may link to others still. So, even if you identify the 10 macros on the toolbar, you may actually need to copy more than those in order to retain functionality.

Again, it's a timeconsuming process if the web is tangled, but it is possible to follow each and every thread. Have patience...and hope another expert comes along with a better solution!
aaepaAuthor Commented:
Thank you... I have it working now - I found the missing macro :).  FYI - there is no way in 2007 or 2010 to edit a custom toolbar that appears in "Add-Ins" (at least that is what I have read in numerous places today!)  It can be added to the quick access toolbar, but not to an "add-in".  
Hi thanks. I'm glad that you're sorted.

The macro should list add-ins with a button starter in Word 2007. It did in my tests.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.