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