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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,221,526
Messages
6,160,340
Members
451,637
Latest member
hvp2262

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