Solved

display a change in document before VBA script ends

Posted on 2012-12-29
2
252 Views
Last Modified: 2012-12-29
I have the following code:
ActiveDocument.Bookmarks("Status").Range.Text = "Clearing All Unneeded Files - Please wait"
ClearAllUneededFiles

Open in new window

The bookmark change does not display until after the subroutine ClearAllUneededFiles completes.  How do I display the bookmark change before running ClearAllUneededFiles?  

TIA
0
Comment
Question by:thenelson
2 Comments
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 38730028
You can add a timer event to delay the code:
Sub YourSub()
Dim Start, Lapse
ActiveDocument.Bookmarks("Status").Range.Text = "Clearing All Unneeded Files - Please wait"
    Lapse = 5 ' Set delay in seconds
    Start = Timer
    Do While Timer < Start + Lapse
        DoEvents
    Loop
ClearAllUneededFiles
End Sub

Open in new window

You can change the line Lapse=5 to however long you want the delay.
Flyster
0
 
LVL 39

Author Closing Comment

by:thenelson
ID: 38730321
I kinda did the same thing you suggested only different:

ActiveDocument.Bookmarks("Status").Range.Text = "Clearing Unneeded Files - Please wait"
Application.OnTime Now + TimeValue("00:00:01"), "ClearAllUneededFiles"
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you how to use shortcut menus in the Access run-time environment.
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question