Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-16-2024, 09:56 AM
gmaxey gmaxey is offline Selection Anomoly Windows 10 Selection Anomoly Office 2019
Expert
Selection Anomoly
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Selection Anomoly Selection.Information not working as intended for selection position m2ramos Word VBA 3 11-07-2022 05:54 AM
Help with Selection VBA JamesWood Word VBA 6 11-17-2020 06:46 AM
Selection Anomoly Is there a way to go to the next selection? wardw Word 2 09-25-2019 09:19 AM
Selection Anomoly Selection.Bookmarks("\headinglevel") WITHOUT Selection NobodysPerfect Word VBA 3 01-14-2015 12:58 PM
Selection Anomoly Selection of all Text for a specific page in word is spanning selection across pages ramsgarla Word VBA 9 12-05-2012 03:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft