View Single Post
  #6   Report Post  
Posted to microsoft.public.word.newusers
John... Visio MVP John... Visio MVP is offline
external usenet poster
 
Posts: 33
Default Newbie macro help please

"Barnet" wrote in message
...
I'm trying to record a macro that will number the pages in my document. I
seem to do OK at first: name the macro, make a keyboard shortcut, begin
recording, execute the commands to put page numbers at the bottom center
of
the document, and then stop recording.

But when I run the macro it stops with 'Runtime error 5941, the requested
member of the collection does not exist.' When I look at debug, it seems
to
show all the steps except for adding the page number itself down in the
footer.

Also, since I've tried this a few times I seem to have to come up with new
names for the macro. Is there a way to erase all the old attempts and old
names to 'clear the slate'?

Thanks in advance,

Barnet



Your error was due to a line like
ActiveDocument.AttachedTemplate.BuildingBlockEntri es("Pg. Number
1").Insert Whe=Selection.Range, RichText:=True

I am not sure why, but it may be a matter of context.

You should be aware, that what the macro recorder records is not always
great code and there may be issues with replaying the macros. With the
Headers/Footers you need to switch windows between the main window and the
H/F window and that may be an issue.

John... Visio MVP