Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pageref woes

44 views
Skip to first unread message

iza

unread,
Aug 28, 2006, 7:29:03 PM8/28/06
to
I am using word 2000 with sp 3. In my document I have to create a weird
TOC: the "chapter names" entries are to be in blue but leader dots and
page numbers in black. The only way I figured out how to do that is to
bookmark the chaptes and construct each "TOC entry" as hyperlink to
the chapter bookmarks + pageref field to the bookmark.
On top of this, I have a VBA macro users need to run to accomplish
other tasks (include files, break links to the included files etc). I
made sure that bookmarks are NOT in included files but in the main
document. This macro also updates fields to show correct page numbers
in TOC - or is supposed to - and here is the problem:

Not all pageref fields in TOC get updated. BTW the pageref are wrong
on screen, but the links work properly...clicking on pageref brings me
to the correct place in the document


If I manually "select all" and press F9 repeteadly several times,
eventually all fields get updated.


So here is the first problem, as the whole process needs to be
automated, I need to be able to implement updating fileds in VBA macro.
I even tried puting Timer in VBA, waiting 10 secnds and updating fields
again, doing this several times, but no cigar.


Also, if I update fieldd manually (so they are all OK) and then switch
to print preview (and back), the pageref fields revert back to
original dummy values. (and yes, option update fields on print is
selected)


Does anyone have a clue why is this happening? Anyone else have seen
something like this? Other articles in this group suggest that PAGEREF
is supposed to work better than sectionpages field or numpages fields,
but for me it seems to be opposite...


Any help will be appreciated


iza

iza

unread,
Aug 28, 2006, 10:36:56 PM8/28/06
to
Partially answering my own question:

selection.EndKey unit:=wdstory
selection.HomeKey unit:=wdstory
ActiveDocument.Fields.Update

with this piece of code, all fields are updated properly. Also works when
manually going to the end of document and then to the top, and updating all
fields- no more multiple updates needed. PrintPreview still messes them up
though...


"iza" <dono...@postoffice.not> wrote in message
news:3%KIg.129729$P02....@fe07.news.easynews.com...

John McGhie [MVP - Word and Word Macintosh]

unread,
Aug 31, 2006, 7:55:38 AM8/31/06
to
Hi iza:

You've found it. The problem is that by the time you come to update the
fields, the document has not completed pagination.

Your macro is as good a way as any of forcing it to do that: it has to
resolve the pagination in order to find the "end".

You could try:

With ActiveDocument
.Repaginate
.Fields.Update
End With

Which is a slightly more elegant way of doing the same thing, but I don;t
trust it. I am not sure that Word will correctly wait for the completion of
the Repaginate before running the fields.update.

However, if it does, ActiveDocument.Fields.Update updates all of the fields
in the document in a single command without any silly prompting as to what
you want to do :-)

Cheers

On 29/8/06 12:36 PM, in article
bLNIg.659272$1Q1.1...@fe03.news.easynews.com, "iza"
<dono...@postoffice.not> wrote:

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <jo...@mcghie.name>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410

ip

unread,
Aug 31, 2006, 2:20:41 PM8/31/06
to
John,
thank you very much - I will try your suggestion.
You woudl not have a clue why print preview messes the pageref numbers
and seq fields ?...

iza

John McGhie [MVP - Word and Word Macintosh]

unread,
Sep 2, 2006, 9:40:44 AM9/2/06
to
Yep. Print Preview sends the document to the "Printer" then intercepts the
result and displays that on the screen (effectively, it tells the printer
driver that the screen is a sheet of paper...)

This will force an update of all fields and a repagination. These are
required to draw an accurate Print Preview.

And if there's anything wrong with your field updating, you will see it...

Cheers


On 1/9/06 4:20 AM, in article
1157048441.9...@p79g2000cwp.googlegroups.com, "ip"

ip

unread,
Sep 6, 2006, 10:59:21 AM9/6/06
to
Thanks John, This is how I understood Print Preview works.
The puzzle is, after updating fields (either manually or from macro)
and then switchign to print preview, the fields revert back to
un-updated state :-((

John McGhie [MVP - Word and Word Macintosh]

unread,
Sep 8, 2006, 6:07:17 AM9/8/06
to
Which fields are we talking about? (What's the field code...)?

I'm not understanding your situation. Every time you go into Print Preview,
hot fields will update. Warm fields will update if you have "Update fields"
set in your Print options. Cold fields will update only if you update them.

Hot fields are those that update continuously: PAGE fields are an example.
Warm fields are those that are updated on document open: DATE fields are an
example. Cold fields are those that must be updated manually: SEQ fields
are an example.

Cheers


On 7/9/06 12:59 AM, in article
1157554761.5...@m79g2000cwm.googlegroups.com, "ip"

mr.da...@gmail.com

unread,
Aug 28, 2016, 12:38:00 PM8/28/16
to
John, 10 years after this post, I wanted to say a big thanks. 2 hours of trying to understand why PageRef fields weren't updating led me nowhere (especially seeing that the code to update seemed perfectly fine, and worked perfectly well when run manually after all the rest of the code had run).

And then I stumbled upon this old thread, and it was the solution I was looking for. The trick was:

With ActiveDocument
.Repaginate
.Fields.Update
End With

Thanks again!
0 new messages