Solved

display a change in document before VBA script ends

Posted on 2012-12-29
2
250 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
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…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now