PDA

View Full Version : Wait for document to load in editing screen



RoyLasris
11-20-2016, 05:05 AM
I have composed a macro that seems to be running 'too fast.' It opens a document (actually it is Inserting text onto a blank editing screen from a referenced document). It then asks the user for responses to questions and then begins to process elements in the document (in particular, scanning text in a table and making 'keep it' or 'delete it' decisions based on answers provided).

Problem is that certain called documents are not visible before the questions are posed. (One document is 26 pages long, contains many tables, and takes about 6 seconds to fully load. Other, shorter, documents don't exhibit this problem.)

The processing actually seems to be occurring correctly, but users are confused when they don't actually see the text (or at least some of it) of document they are working on. In some cases, though (typically slower computers), there appears to be buffering occurring, and when the buffer is full --because of the delays in the screen repainting -- the process crashes.)

How can I pause processing of the code until the text is actually visible on the screen?

I have tried Wait and Sleep functions, but they seem to suspend all activity, including screen displays. Plus, while I may want to pause operations for 6 seconds for that very long document I mentioned, I don't need to pause it at all for the short ones. Can VBA paused processing just until it detects that something is actually on the screen?

gmaxey
11-20-2016, 07:10 PM
Just a stab and not tested:

DoEvents
Application.ScreenRefressh
DoEvents