Solved

display a change in document before VBA script ends

Posted on 2012-12-29
2
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Outlook Free & Paid Tools
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

691 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