Accept all track changes on a group of documents

  • Thread starter Thread starter JR
  • Start date Start date
J

JR

I have about 50,000 documents that I want to accept any changes in
them and remove any comments from the document. Any kind of macro or
something that can do this bulk on aoo documents in a folder?

Thanks.

JR
 
JR said:
I have about 50,000 documents that I want to accept any changes in
them and remove any comments from the document. Any kind of macro or
something that can do this bulk on aoo documents in a folder?

Thanks.

JR

The basic code for batch processing the contents of a folder is as follows.
The example shown will accept all changes in the documents and remove
comments. http://www.gmayor.com/installing_macro.htm

50,000 is a hell of a lot of documents for a single folder? It would be
better to split this into more manageable chunks. Either way it is going to
take some time to run, so test on a subset to ensure that it does what you
want.

Sub BatchProcessings()
Dim myFile As String
Dim PathToUse As String
Dim MyDoc As Document
Dim iFld As Integer

'Select the folder top process
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
'Close and prompt to save any open documents
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If
myFile = Dir$(PathToUse & "*.do?")
While myFile <> ""
Set MyDoc = Documents.Open(PathToUse & myFile)
'**********************************************
'Apply the code in this section to each document
With WordBasic
.AcceptAllChangesInDoc
.DeleteAllCommentsInDoc
End With
'**********************************************
'Save and close the document and open the next
MyDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub
 
The basic code for batch processing the contents of a folder is as follows.
The example shown will accept all changes in the documents and remove
comments.http://www.gmayor.com/installing_macro.htm

50,000 is a hell of a lot of documents for a single folder? It would be
better to split this into more manageable chunks. Either way it is going to
take some time to run, so test on a subset to ensure that it does what you
want.

Sub BatchProcessings()
Dim myFile As String
Dim PathToUse As String
Dim MyDoc As Document
Dim iFld As Integer

'Select the folder top process
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
'Close and prompt to save any open documents
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If
myFile = Dir$(PathToUse & "*.do?")
While myFile <> ""
Set MyDoc = Documents.Open(PathToUse & myFile)
'**********************************************
'Apply the code in this section to each document
With WordBasic
.AcceptAllChangesInDoc
.DeleteAllCommentsInDoc
End With
'**********************************************
'Save and close the document and open the next
MyDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub

This is great. Thanks for the help. Didn't realize there was a
WordBasic function called DeleteAllCommentsInDoc. Wish the WordBasic
stuff was documented somewhere. Doesn't seem to be a lot of info on
it. Yahoo comes up with like three hits if you search on WordBasic
and DeleteAllCommentsInDoc.

Is there something similar if you want to remove all Macros in a
document as well regardless of what it is?

Thanks.

JR
 
The basic code for batch processing the contents of a folder is as follows.
The example shown will accept all changes in the documents and remove
comments.http://www.gmayor.com/installing_macro.htm

50,000 is a hell of a lot of documents for a single folder? It would be
better to split this into more manageable chunks. Either way it is going to
take some time to run, so test on a subset to ensure that it does what you
want.

Sub BatchProcessings()
Dim myFile As String
Dim PathToUse As String
Dim MyDoc As Document
Dim iFld As Integer

'Select the folder top process
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
'Close and prompt to save any open documents
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If
myFile = Dir$(PathToUse & "*.do?")
While myFile <> ""
Set MyDoc = Documents.Open(PathToUse & myFile)
'**********************************************
'Apply the code in this section to each document
With WordBasic
.AcceptAllChangesInDoc
.DeleteAllCommentsInDoc
End With
'**********************************************
'Save and close the document and open the next
MyDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub

By the way, the code is erroring on the .DeleteAllCommentsInDoc
command. Get a runtime error 509. This command is not available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top