Word 2007 Macro Error when Changing Footer

D

DNatt2

Note: I posted this question in the Office Developer > Automation forum last
week, but did not receive a reply. I'm hoping the Word > Programming forum
has a wider audience, since this is a showstopper problem for me:

I started the macro recorder in Word 2007 B2TR, and then did the following
steps:

1. Clicked the "Insert" tab on the ribbon.
2. Clicked Page Number > Bottom of Page > Bold Numbers 2. (This is one of
the selections under the "Page X of Y" category).
3. Stopped the Macro recorder.

Unfortunately, the very simple macro code that was generated (see below)
does not appear to work. If I immediately create a new document and try to
run the macro (By clicking "View > Macros > [select my macro in the list] >
Run", I get a dialog that says, "Run-time error '5941': The requested member
of the collection does not exist.". Here is the macro code:

Sub Macro1()

Macro1 Macro

WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Bold Numbers 2"). _
Insert Where:=Selection.Range, RichText:=True
End Sub

When I click "Debug", it highlights the "ActiveDocument..." and "Insert..."
lines above. Needless to say, I get an error when calling this code in an
application outside Word as well. Can anybody help me figure out why this
isn't working?

The reason I need to fix this is that I already have macro code that I used
with Word 2000, XP, and 2003 that used the "AutoTextEntries" collection. I
was easily able to set an AutoTextEntry of "Page X of Y" to set up a footer
of that format. But AutoText seems to be nonfunctional in Word 2007, and I
can't figure out how to get a footer that says "Page X of Y" as a result.

Thanks, and please let me know if you need any more information to help me
diagnose my problem.

-D
 
D

DNatt2

FYI, I got a response on my thread in the Office Developer > Automation
forum. So any questions/discussion related to this issue (which is not yet
resolved) should probably be directed over there.

Thanks,
-D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top