[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

display a change in document before VBA script ends

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
thenelson
Asked:
thenelson
1 Solution
 
FlysterCommented:
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
 
thenelsonAuthor Commented:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now