Macro problem with inserting page number

  • Thread starter Thread starter kalispunk
  • Start date Start date
K

kalispunk

I'm trying to write a simple macro that would add Page X of Y to the bottom
of pages. The macro works (Insert, Page no., Bottom of page) until I have to
scroll down the list to find Page X of Y. At that point it just freezes and
won't recognize that I'm scrolling.

I tried to pause the macro at that point, but somehow when I run the macro
it does not pause.

What should I do?

Thanks,
Kim
 
I am not sure why you would want to use a macro to do that, but the
following is what you should use:

Dim rng As Range
With ActiveDocument
Set rng = .Sections(1).Footers(wdHeaderFooterPrimary).Range
rng.Collapse wdCollapseEnd
rng.Text = "Page "
Set rng = .Sections(1).Footers(wdHeaderFooterPrimary).Range
rng.Collapse wdCollapseEnd
.Fields.Add rng, wdFieldPage
Set rng = .Sections(1).Footers(wdHeaderFooterPrimary).Range
rng.Collapse wdCollapseEnd
rng.Text = " of "
Set rng = .Sections(1).Footers(wdHeaderFooterPrimary).Range
rng.Collapse wdCollapseEnd
.Fields.Add rng, wdFieldNumPages
With .Sections(1).Footers(wdHeaderFooterPrimary).Range
.Paragraphs(1).Alignment = wdAlignParagraphCenter
.Fields.Update
End With
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
Back
Top