Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-28-2011, 02:09 AM
macropod's Avatar
macropod macropod is offline Replace text in multiple documents? Windows 7 32bit Replace text in multiple documents? Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by atrivedi View Post
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
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 01-28-2011 at 02:17 AM. Reason: Deleted unnecessary message box (left over from testing)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace All with plain text containing subscript DeaducK Word 0 06-24-2010 08:16 PM
Replace formatting with text eyehefbee Word 2 11-09-2009 02:41 AM
Replace text in multiple documents? Generating multiple documents from 1 data source themangoagent Word 2 08-14-2009 12:12 PM
2007 merging multiple documents into one master hugheso Word 0 04-02-2009 04:31 AM
Replace text in multiple documents? page numbering across multiple documents reitdesign Word 3 12-12-2008 11:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft