"Page 2 of 1" annoyance

E

elle0612

I have coded a document template with userform.

Why is it that the second page of my "New" .doc from the template states
"Page 2 of 1" yet when I double click straight in the footer on the page
number, it changes to the correct state of "Page 2 of 2", as if it required a
kick start.

This is a puzzling problem. Any answers out there?

thanks
 
R

Russ

Elle,

This code, that someone else wrote, will update every field in a document.
You can run it from another macro by
Call UpdateAllFields


Sub UpdateAllFields()
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
End Sub
 
D

Doug Robbins - Word MVP

Or use

With ActiveDocument
.PrintPreview
.ClosePrintPreview
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
 
E

elle0612

Where do you recommend putting this code?

I suppose I would somehow need an if statement, if pages >1 then do the code
you advised.

There would be no point putting this code anywhere within the modal userform
code, as the form is gone before the user starts typing on the actual
document.

What about somehow within the "this document" code?

Thanks
 
D

Doug Robbins - Word MVP

I had thought that your application was creating a two page document. If
the second page is only added because the user continues past the first
page, then the field should update automatically. Does that not happen for
you with an ordinary document (one created without the use of your
template.)?

--
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
 
E

elle0612

Yes, it does normally happen ok. I've now tried it on the actual template
iteself and I get "Page 2 of 2" like I'm supposed to, but on creating a new
docment from the template I get "Page 2 of 1" - but on double clicking in the
footer on second page, it correctly reverts to "Page 2 of 2".

I have tried using both the autotext Page x of y, and also " Page CtrlF9
{PAGE} OF Ctrl F9 {NUMPAGES}" within the template itself. I have stopped it
showing on first page.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top