View Single Post
  #7   Report Post  
Posted to microsoft.public.word.newusers
Barnet Barnet is offline
external usenet poster
 
Posts: 26
Default Newbie macro help please

Hi John,

Thanks so much, we're getting close. Let me show you what the debug window
displays:

WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntri es(" Blank").Insert _
Whe=Selection.Range, RichText:=True
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntri es("Plain Number 2"). _
Insert Whe=Selection.Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

Now, I know absolutely zippo about Visual Basic. I have noticed that it
seems to want to put "Plain Number 2" in, whereas I'd think it would want to
insert the symbol for successive page numbers (whatever that would be).

I have tried to create this macro both by going straight to the page number
tab, and also by first opening a footer, selecting "blank", and then using
the page number tab. I then have to use the Exit Footer (or whatever it's
called) button to get back to the main document.

But no matter what I try it ends up with the error messages above.

Thanks for taking the time with my question, I appreciate it.

Barnet

"John... Visio MVP" wrote:

"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