pageref woes

I

iza

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
 
I

iza

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...
 
J

John McGhie [MVP - Word and Word Macintosh]

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

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

--

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

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410
 
I

ip

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
 
J

John McGhie [MVP - Word and Word Macintosh]

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


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

--

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

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410
 
I

ip

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 :-((

iza
 
J

John McGhie [MVP - Word and Word Macintosh]

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


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 :-((

iza

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


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] wrote:
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
[email protected], "iza"

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


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






--

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

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410

--

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

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410

--

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

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410
 

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