View Single Post
 
Old 06-16-2024, 09:56 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Well, I wallowed around in this one long enough. It seems that simply adding a DoEvents after the Documents.Add method eliminates the anomaly.

Sub Demo_LostSelection_AnomolyI()
Dim oRng As Range
Dim oDocTmp As Document
ActiveDocument.Range.Text = "One two three"
ActiveDocument.Words(1).Select
Set oDocTmp = Documents.Add
DoEvents
oDocTmp.Close wdDoNotSaveChanges
'Notice after the procedure runs that the selection is reset to the start of the page.
lbl_Exit:
Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote