Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-11-2022, 11:34 AM
BrianHoard BrianHoard is offline Why does the document get selected after undo-ing my script? Windows 10 Why does the document get selected after undo-ing my script? Office 2019
Advanced Beginner
Why does the document get selected after undo-ing my script?
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Thanks for the help with the variables. I have changed them all to be individual Dim statements. But even after that, the problem is still there. Hitting Undo after running my script selects the entire document for some reason.
Reply With Quote
  #2  
Old 09-11-2022, 01:23 PM
BrianHoard BrianHoard is offline Why does the document get selected after undo-ing my script? Windows 10 Why does the document get selected after undo-ing my script? Office 2019
Advanced Beginner
Why does the document get selected after undo-ing my script?
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Finally found the problem!!!

It was where I was setting the Endnote options to use regular numbers. Turns out if the document was already using this option, me setting it again caused the document to get selected if the script was undone. So I added the following if statement which solved the problem, only changing the option if needed.


Code:
  If Not ActiveDocument.Range.EndnoteOptions.NumberStyle = 0 Then
    ActiveDocument.Range.EndnoteOptions.NumberStyle = 0
  End If
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a selected range of a document to a new document with preserving formatting,header and footer RobertDany Word VBA 10 08-10-2021 04:04 AM
Insert Comments from List for Whole Document and for Only Selected Portion of Document rekent Word VBA 8 11-10-2020 11:01 PM
Why does the document get selected after undo-ing my script? Copy selected text from one document and paste to new document in same position on the page gasparik Word VBA 1 05-11-2020 05:41 AM
Why does the document get selected after undo-ing my script? When multiple documents open, undo/redo in one document affects others? seanspotatobusiness Word 3 07-28-2018 03:15 PM
Why does the document get selected after undo-ing my script? Can I undo a repaired document? uberscribbler Word 2 11-18-2014 11:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:51 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