Hi Steve, I routinely use these three in my macros (albeit without the full understanding of their purpose). None of these methods seem to work in the case I described though. I also tried brut force methods of closing and re-opening the document but they didn't work consistently. You also suggested that this could be due to draw objects in the headers and footers or, due to long tables with complex pagination. I think that in our case the second option (long tables) may apply. Is there another way to get around this problem? Cheers, Alon |--------+----------------------------------> | | "Steve Hudson" | | | <cruddy@xxxxxxxxxxxxxxxx| | | > | | | Sent by: | | | austechwriter-bounce@fre| | | elists.org | | | | | | | | | 26/07/2003 02:42 PM | | | Please respond to | | | austechwriter | | | | |--------+----------------------------------> >----------------------------------------------------------------------------------------------------------| | | | To: <austechwriter@xxxxxxxxxxxxx> | | cc: | | Fax to: | | Subject: [austechwriter] Re: Word pagination stops during the execution of a macro | >----------------------------------------------------------------------------------------------------------| My Word VBA Spellbook has this to offer as generic advice, it's well worth the purchase price: The Unholy trinity This is the "Maggie" equivalent for VBA logic problems, like when Word goes splat halfway through a long code run. Memorize these functions for their aid is always magnificent! The unholy trinity are UndoClear, DoEvents and OnTimer. All three have excellent help in Word's built-in help system that is not worth repeating here. DoEvents DoEvents forces your code to take a back seat so that any background processes can use some CPU time. Miscellaneous errors are fixed just through adding in a DoEvents to force a hand-off to other tasks waiting in the wings. It is especially useful when updating UserForms, dealing with external applications or simply letting the pagination engine paginate. So when code asks some other sub-system to do something and needs the result, follow it up with a DoEvents. Undo Note there is no simple way to access the undo collection, thus it is difficult to get all your VBA actions to be in undo step. A poor workaround is to clear the undo collection before your macro so that you can undo all actions to just undo the macro. Regardless, you should regularly clear the buffer if you are doing automated editing using ActiveDocument.UndoClear. OnTimer OnTimer delays your code execution for a few seconds. Nothing is running so Word has a chance to do its things. This is especially useful during document open where Word runs auto-executing code before it has quite finished setting up the environment. It particularly manifests itself in problems like being unable to do stuff to UserForms and CommandBars on document open. It also fixes sporadic error 5 conditions on startup. It works best when called last in the sub routine to prevent long running code in the first sub-routine from interfering with the pause effect. Old Subroutine Public Sub AutoExec() 'A whole bunch of safe stuff MyForm.Show 'start of bad stuff block End Sub The replacement waits for two seconds before running the offending code. Public Sub AutoExec() 'A whole bunch of safe stuff Application.OnTime When:=Now + TimeValue("00:00:02"), Name:=" DelayedAutoExec" End Sub Public Sub DelayedAutoExec() MyForm.Show 'start of bad stuff block End Sub Steve Hudson Word Heretic, Sydney, Australia Tricky stuff with Word or words for you. Email: steve@xxxxxxxxxxxxxxx Products: http://www.geocities.com/word_heretic/products.html Spellbooks: 728 pages of dump left and dropping... -----Original Message----- From: austechwriter-bounce@xxxxxxxxxxxxx [mailto:austechwriter-bounce@xxxxxxxxxxxxx]On Behalf Of Alon_Hadass@xxxxxxxxxxxx Sent: Friday, 25 July 2003 1:59 PM To: austechwriter@xxxxxxxxxxxxx Subject: [austechwriter] Word pagination stops during the execution of a macro Hi, During the execution of a macro I am trying to insert an index into the document. No matter what I do, Word's automatic pagination kicks in and at some point gets "stuck". All further macro commands are suspended until you press ESC to stop the pagination. I have played with different extreme solutions (open and close document, change views, force repagination) but none of them work consistently. Inserting the index manually or simply stepping through the macro works just fine. Any advice on why this may happen and how I can stop this from occurring? Regards, Alon Hadass ************************************************** To post a message to austechwriter, send the message to austechwriter@xxxxxxxxxxxxxx To subscribe to austechwriter, send a message to austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field. To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with "unsubscribe" in the Subject field. To search the austechwriter archives, go to www.freelist.org/archives/austechwriter To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx ************************************************** ************************************************** To post a message to austechwriter, send the message to austechwriter@xxxxxxxxxxxxxx To subscribe to austechwriter, send a message to austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field. To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with "unsubscribe" in the Subject field. To search the austechwriter archives, go to www.freelist.org/archives/austechwriter To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx ************************************************** ************************************************** To post a message to austechwriter, send the message to austechwriter@xxxxxxxxxxxxxx To subscribe to austechwriter, send a message to austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field. To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with "unsubscribe" in the Subject field. To search the austechwriter archives, go to www.freelist.org/archives/austechwriter To contact the list administrator, send a message to austechwriter-admins@xxxxxxxxxxxxx **************************************************