You'll need a macro. The following will open all the DOC format files in a
folder selected from the macro, find the strings defined at vFindText and
replace them all with the same string defined at vReplText, then saves as
RTF format in the same folder. The original document is closed without
saving the changes.
May I suggest that you test it on a couple of documents in a temporary
folder to ensure that it catches all the changes.
http://www.gmayor.com/installing_macro.htm
Sub SaveAllAsRTF()
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim Response As Long
Dim fDialog As FileDialog
Dim vFindText As Variant
Dim vReplText As String
Dim i As Long
vFindText = Array("Licence No AA", "Licence No BB", "Licence No CC")
vReplText = "Licence No XX"
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "Save all as RTF"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
strFileName = Dir$(strPath & "*.doc")
While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText
.Execute Replace:=wdReplaceAll
Next i
End With
End With
strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".rtf"
oDoc.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatRTF, AddtorecentFiles:=False
oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>