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

Pause before TOC insertion?

0 views
Skip to first unread message

Joan Edington

unread,
Jun 22, 2001, 6:52:00 AM6/22/01
to
Hi,

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

Doug Robbins

unread,
Jun 22, 2001, 7:56:02 AM6/22/01
to
Hi 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...

Jonathan West

unread,
Jun 22, 2001, 7:48:09 AM6/22/01
to
Hi Joan

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

Joan Edington

unread,
Jun 23, 2001, 8:09:33 AM6/23/01
to
On Fri, 22 Jun 2001 12:48:09 +0100, "Jonathan West" <jw...@mvps.org>
wrote:

>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

Joan Edington

unread,
Jun 23, 2001, 8:11:38 AM6/23/01
to
On Fri, 22 Jun 2001 21:56:02 +1000, "Doug Robbins"
<drob...@eisa.net.au> wrote:

>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

Jay Freedman

unread,
Jun 23, 2001, 9:48:57 AM6/23/01
to
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 .

Regards,
Jay

Joan Edington <Joan_L_...@compuserve.com> wrote in message

news:ui19jt4liqcfph6fk...@4ax.com...

Doug Robbins

unread,
Jun 23, 2001, 9:42:52 PM6/23/01
to
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

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

Joan Edington

unread,
Jun 24, 2001, 8:40:03 AM6/24/01
to
On Sat, 23 Jun 2001 09:48:57 -0400, "Jay Freedman"
<jay.fr...@verizon.net> wrote:

>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

0 new messages