unable to refresh document window from Word vba

Clif McIrvin

New Member
Joined
Dec 22, 2023
Messages
11
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I just discovered that there is some discussion of Word vba here.
In Excel, I am used to being able to turn screen updating on and off, and programmatically trigging screen refresh at will.
Working with Word vba I have found what should be the appropriate commands; but I cannot make the screen refresh while my code is running.
For instance- this code snippet:
VBA Code:
Set r = Selection.Range 'begin search at user selected location
r.Expand wdSentence
Application.ScreenUpdating = False
ActiveWindow.ScrollIntoView r
Application.ScreenUpdating = True
DoEvents

varText = "Build Sub/Function headings?" & vbCrLf & _
   "Is " & r.Text & vbCrLf & _
   "where the search should begin?"
 
Select Case MsgBox(varText, vbYesNoCancel, "Mark Sub/Function Headings")
does not refresh the screen until my code has finished running.
I have also tried
VBA Code:
Application.ScreenRefresh
What I am trying to do is to have the document window scroll to the correct position before the MsgBox displays.
Suggestions?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top