Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro problem with inserting page number
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 |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro problem with inserting page number
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 "kalispunk" wrote in message ... 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 |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro problem with inserting page number
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 "kalispunk" wrote in message ... 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 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting footnote makes page number mysteriously appear at top ed | Microsoft Word Help | |||
Chapter Number - Page Number Problem | Page Layout | |||
inserting page number in office word | Microsoft Word Help | |||
Number of page disappeared after formula inserting | Microsoft Word Help | |||
How do I insert a page number without it inserting {PAGE}? | Microsoft Word Help |