Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2023, 09:44 AM
pjs15 pjs15 is offline Track Changes check in a macro? Windows 10 Track Changes check in a macro? Office 2019
Novice
Track Changes check in a macro?
 
Join Date: Feb 2020
Posts: 7
pjs15 is on a distinguished road
Default Track Changes check in a macro?

I have a macro that cleans up a Word document, doing things like changing line breaks to paragraph marks, changing curly quotes to regular ones, changing double hyphens to an em-dash, and the like. If the document comes in with Track Changes on, and I execute the macro without turning that function off, it goes into an endless loop and crashes Word.



Is there a way to have the macro begin with a command to check if Track Changes is on and, if yes, to turn it off?

Thanks for any help.
Reply With Quote
  #2  
Old 01-05-2023, 02:39 PM
macropod's Avatar
macropod macropod is offline Track Changes check in a macro? Windows 10 Track Changes check in a macro? Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Yes, that can be done, but even that might not be sufficient. Typically, a Find/Replace macro, for instance, needs to be coded so it processes the document backwards. That is typically achieved by changing:
.Forward = True
and, if your code uses it
.Collapse wdCollapseEnd
to:
.Forward = False
and
.Collapse wdCollapseStart
respectively.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-08-2023, 09:11 PM
Charles Kenyon Charles Kenyon is offline Track Changes check in a macro? Windows 11 Track Changes check in a macro? Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,470
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Code:
Dim bTrackChanges As Boolean
Let bTrackChanges = ActiveDocument.TrackRevisions
Let ActiveDocument.TrackRevisions = False
' Your code here
Let ActiveDocument.TrackRevisions = bTrackChanges

Note that often a password is needed to turn off track changes.
Reply With Quote
  #4  
Old 01-09-2023, 07:49 AM
pjs15 pjs15 is offline Track Changes check in a macro? Windows 10 Track Changes check in a macro? Office 2019
Novice
Track Changes check in a macro?
 
Join Date: Feb 2020
Posts: 7
pjs15 is on a distinguished road
Default

Many thanks, Charles. That certainly works. I discovered the proper wording for Track Changes, and starting the macro with this also works:

ActiveDocument.TrackRevisions = False
Reply With Quote
  #5  
Old 01-09-2023, 01:52 PM
macropod's Avatar
macropod macropod is offline Track Changes check in a macro? Windows 10 Track Changes check in a macro? Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Do note that switching Tack Changes off means the changes made by your macro won't be tracked.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
macro, track changes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Track Changes check in a macro? Macro in Word to track colour of highlighted text BABZ Word VBA 1 01-09-2017 10:33 PM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
Track Changes check in a macro? Macro to replace text and track changes based on user-defined rules Thefirstfish` Word VBA 13 01-09-2016 07:14 AM
Track Changes check in a macro? Someone please check my macro BIMwit Excel Programming 6 06-13-2015 12:04 PM
Track Changes check in a macro? Check Box Macro Johnny thunder Word VBA 12 04-07-2011 04:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:39 PM.


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