Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
kalispunk kalispunk is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting footnote makes page number mysteriously appear at top ed Jackie1776 Microsoft Word Help 2 May 14th 09 02:31 PM
Chapter Number - Page Number Problem Jen Page Layout 1 April 21st 09 09:34 AM
inserting page number in office word Nisha Singh Microsoft Word Help 1 March 2nd 09 10:52 PM
Number of page disappeared after formula inserting RN Microsoft Word Help 6 November 21st 06 02:11 PM
How do I insert a page number without it inserting {PAGE}? austin Microsoft Word Help 1 June 3rd 06 04:49 PM


All times are GMT +1. The time now is 07:33 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"