Quote:
Originally Posted by atrivedi
Please follow the directions below to replace text in multiple documents. This is the only solution to replacing text in multiple documents for Microsoft Word.
|
All I can say to that, is nonsense! A macro can be used to automate searching across as many files as you want.
Roscoe: Try a macro like:
Code:
Sub Update_RTF_File_Sigs()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, RTFDoc
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.rtf", vbNormal)
While strFile <> ""
Set RTFDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With RTFDoc.Range.Find
.ClearFormatting
.Text = "Old Address"
.Replacement.Text = "New Address"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
RTFDoc.Close SaveChanges:=True
strFile = Dir()
Wend
Set RTFDoc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
The macro allows you to browse to the folder containing the rtf files you want to process, then processes all such files in that folder automatically.
Of course, you'll need to change the 'Old Address' & 'New Address' details to suit your requirements. In this regard, if an address is in the form of:
Address Line 1¶
Address Line 2
the .Text and/or .Replacement.Text expressions (as required), would become:
= "Address Line 1^pAddress Line2"
In case you need advide on how to install & run a macro, see:
http://www.gmayor.com/installing_macro.htm