Avatar of openaccount1
openaccount1 asked on

Automatically accept all changes, delete all comments and switch off Track Changes in MS Word

We have a writer writing in articles for us and then someone else is commenting on the articles and doing deletions in the word documents and the changes are also being tracked because change tracking is enabled. But when everything is done we will need to open each document, accept all changes, delete all coments, and switch off Track changes. And we will do this each time on every document. Is there a way to do these actions:

1. Accept all changes
2. Delete all coments
3. Swithc off Track changes.

in Batch so that we do not need to do these one by one. It may be a macro (Please teach me how to use it if it is a macro because I really do not know macro) or a VB executable script so that all actions mentioned above can be automatically done without opening the word files individually.

Thanks.
VB ScriptVisual Basic ClassicMicrosoft Word

Avatar of undefined
Last Comment
openaccount1

8/22/2022 - Mon
ExcelGuide

Goto Tools>Macro>Visual Basic Editor

Double click on "ThisDocument" under "Microsoft Word Objects"

Copy/paste the code below.

Exit the editor

Goto Tools>Macro and click on the play button "macros" and select the macro "change" en run this.

This will do the trick, good luck.
sub change()
Dim arev As Revision
With ActiveDocument
For Each arev In .Revisions
arev.Accept
Next arev
End With
 
ActiveDocument.DeleteAllComments
ActiveDocument.TrackRevisions = Not ActiveDocument.TrackRevisions
 
end sub

Open in new window

ASKER
openaccount1

WIll this be able to do a batch change or update all files in one go?
ExcelGuide

this is only for one file. But can be done in one of the office tools (like Word, Excel etc.)

This also can be done in a VBS script as well.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
openaccount1

OK, I am not a programmer. Can you send the vb script equivalent of the macro... and the instruction on how to use it please...

Thank you so much.
dlc110161

You can do this with VBA.  The below code assumes that all the files you want to change are in the same folder. (C:\MyDocs)

You will need to add the FileSystemObject to your references.
1. Open the VBE
2. Tools
3. References
4. Locate "Microsoft Scripting Runtime"
5. Place a checkmark in the option and click OK

Dawn Crosier-Bleuel
Word MVP
Sub ChangeFiles
	Dim fso As FileSystemObject
	Dim objFolder As Folder
	Dim objFile As File
	Dim strName As String
 
	Set fso = New FileSystemObject
	Set objFolder = fso.GetFolder("C:\MyDocs")'Or the folder you nead searched
 
	For Each objFile In objFolder.Files
		strName = objFile.Path
 
		If Right(strName, 4) = ".doc" Then
			Application.Run MacroName:="change" 'Or whatever you named your other macro
		End If
	Next
End Sub

Open in new window

ASKER
openaccount1

Sorry... Newby here when it comes to macros or VB code. :( Can't understand... Please bear with me.... I think I may get it if you provide a word document with screenshot of what to do.

1. How and where to add the code.
2. How to execute the code.

Thank you so much.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ExcelGuide

see example.

I used my code and the code from Dawn Crosier-Bleuel, just modified this code a bit and also added more.

The only thing you have to do is just click on the button in the word document. You will be asked to choose a folder where the file are located. Then the code will be runned automatically.

Please split points between me and Dawn. Thanks.

Good luck.
example.doc
ASKER
openaccount1

Hi Again,

Another question. I double click the button in the document that you provided and it opened in the VB editor. I then click the "Play" button and an error showed up saying that the macros in the project are disabled. How can I enable it? Sorry for the bother. I really do not have knowledge about this thing.
ASKER
openaccount1

Hi,

I was able to enable the macro and yes it asked for the folder on where the documents are. However, the documents were not changed. Comments and change tracking is still visible.

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
dlc110161

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ExcelGuide

I see we forgot more. I just tested the code and no it was not working. I modified the code a bit and now it is working.

for your information:
I added some lines to actually open the file, run the macro, save and close the file.

Good luck
example.doc
ASKER
openaccount1

Hi again...

There is another error. It only opens the first document that it sees and not all documents in the folder. Also, after doing the changes can it just automatically save and close the file? Because currently it is asking you to save and close the file.


Thanks.
ExcelGuide

sorry didnt test this with several files, fixed the problem.

btw I did not get the question to save the file? please try this one again.
example.doc
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
openaccount1

The code is working correctly now and all files are being changed. One last thing, when the files are being changed a pop up is appearing. Can this popup be eliminated? Tried the code on both Wird 2003 and 2007 and same result. See attached file for screenshot of the pop up.

Thank you.
popup.png
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
openaccount1

Great! Everything is ok now. Thanks for the very big help.
ASKER
openaccount1

Excellent Solution! Thank you very much! I want to reward you both more that 500 points but unfortunately 500 points is the highest.
Your help has saved me hundreds of hours of internet surfing.
fblack61