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
Solved

display a change in document before VBA script ends

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
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…

856 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