Solved

Macros / Custom Toolbar Help - Word 2007/2010

Posted on 2010-09-21
5
1,335 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:aaepa
  • 2
  • 2
5 Comments
 
LVL 8

Assisted Solution

by:PandaPants
PandaPants earned 250 total points
ID: 33729457
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.
0
 
LVL 8

Expert Comment

by:PandaPants
ID: 33729502
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!
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 33733400
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
                    
                    but.CopyFace
                    Set rng = rw.Cells(4).Range
                    rng.Collapse wdCollapseStart
                    rng.Paste
                End If
            End If
        Next but
    Next bar
End Sub

Open in new window

0
 

Author Closing Comment

by:aaepa
ID: 33736795
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".  
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 33738182
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.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This article will show you how to use shortcut menus in the Access run-time environment.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question