My current task is to produce Word documents in a specified format
depending on content passed from an Access DB, and I am only a newbie
to VB.
All is well at first. The data is passed over and all the text
manipulation carried out fine. However, the manipulation involves the
insertion of several page breaks. The last step is to insert the TOC
but the background pagination hasn't caught up with the new page
numbers and the TOC is all wrong.
I know that the code works because if I stop before that, let the
pagination catch up, then run the TOC code all is OK.
I need some way of waiting till the pagination has finished before
inserting the TOC.
I have tried time loops, msgbox waits, saves and even closing and
re-opening the document, all to no avail. In the case of the waiting
style the background task seems to stop as well. In the case of the
saves and closes the document doesn't appear to consider pagination a
change to the document and closes it in the unamended state.
Ideally there would be a document property that says when it is up to
date, but I can't find such a thing.
Please could someone answer this very frustrating problem of mine. It
should be so easy!
Regards,
Joan
How about updaating the TOC after it is inserted.
ActiveDocument.TablesOfContents(1).UpdatePageNumbers
should do it.
Please post any follow-up or new questions to the Newsgroups so that others
may benefit therefrom or contribute thereto.
Hope this helps,
Doug Robbins - Word MVP
"Joan Edington" <Joan_L_...@compuserve.com> wrote in message
news:jn86jt8gdap5rje5d...@4ax.com...
If you put in the line
ActiveDocument.Repaginate
it will force a foreground repagination, before the next line of code is
run.
--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email
"Joan Edington" <Joan_L_...@compuserve.com> wrote in message
news:jn86jt8gdap5rje5d...@4ax.com...
>Hi Joan
>
>If you put in the line
>
>ActiveDocument.Repaginate
>
>it will force a foreground repagination, before the next line of code is
>run.
That's what I thought and I had already tried it I'm afraid. The same
thing happened. It didn't wait for the page numbering to complete.
Is there no way of pausing VB code?
Joan
>Hi Joan,
>
>How about updaating the TOC after it is inserted.
>
>ActiveDocument.TablesOfContents(1).UpdatePageNumbers
>
>should do it.
>
Sorry. I'd already tried that too. It just updated so quickly that
the pages hadn't caught up.
Joan
If you need a few seconds of delay, use the Application.OnTime method.
Besides the description in the Help file, there's a code sample at
http://www.mvps.org/word/FAQs/Userforms/AutoExecUsertFm.htm .
Regards,
Jay
Joan Edington <Joan_L_...@compuserve.com> wrote in message
news:ui19jt4liqcfph6fk...@4ax.com...
Maybe Jay's suggestion of a timer is the way to go. But you could just try
inserting
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
Before the
ActiveDocument.TablesOfContents(1).UpdatePageNumbers
Please post any follow-up or new questions to the Newsgroups so that others
may benefit therefrom or contribute thereto.
Hope this helps,
Doug Robbins - Word MVP
"Joan Edington" <Joan_L_...@compuserve.com> wrote in message
news:ko19jtgogse67i8j5...@4ax.com...
>Hi, Joan,
>
>If you need a few seconds of delay, use the Application.OnTime method.
>Besides the description in the Help file, there's a code sample at
>http://www.mvps.org/word/FAQs/Userforms/AutoExecUsertFm.htm .
>
On Sun, 24 Jun 2001 11:42:52 +1000, "Doug Robbins"
<drob...@eisa.net.au> wrote:
>Hi Joan,
>
>Maybe Jay's suggestion of a timer is the way to go. But you could just try
>inserting
>
> ActiveDocument.PrintPreview
> ActiveDocument.ClosePrintPreview
>
>Before the
>
>ActiveDocument.TablesOfContents(1).UpdatePageNumbers
>
Thanks to both of you for these suggestions.
I tried both and both worked. Unfortuneately I had re-booted my PC and
everything was going faster. My original was paginating in time too!
I'm going to make the document a bit bigger and see which works best.
I've stashed the timer method away in the memory banks for the future
anyway.
Thanks again.
Joan