![]() |
#1
|
|||
|
|||
![]()
Good Day,
I have a big number of word files containing text. after finalizing the files, I found out that I need to replace some particular repeated words in all the files. It's not practical to open each file and replace the text and then open the next file. is there any way to replace some text in multiple files at one time with a new text Thanks in advance |
#2
|
||||
|
||||
![]()
Hi alysolyman,
Is this just a couple of words that need replacing in each file, or a large list?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
This may work for you:
http://gregmaxey.com/word_tip_pages/...d_replace.html |
#4
|
|||
|
|||
![]()
If it is a simple replace over a number of files, using DIR would be the simplest way to go.
|
#5
|
||||
|
||||
![]()
Hir Gerry,
I'm sure you realize it's a little more complicated than that ... I suspect Greg's Addin uses the Dir command for the batch processing option.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]()
Hi Paul. I am sure Greg's addin does use DIR. It is a very useful tool.
My point was that if it is a simple (say a single word or phrase) operation, then it actually is NOT all that complicated. Code:
Sub ChangeSomething() Dim file Dim path As String Dim r As Range path = "c:\ThisOne\" file = Dir(path & "*.doc") Do While file <> "" Documents.Open path & file Set r = ActiveDocument.Range r.Find.Execute FindText:="this phrase", _ ReplaceWith:="booga booga whatever", Replace:=wdReplaceAll ActiveDocument.Save ActiveDocument.Close file = Dir() Loop End Sub The OP asked: "is there any way to replace some text in multiple files at one time with a new text" The answer of course is, yes. |
#7
|
|||
|
|||
![]()
Thanks a lot to all of you
|
#8
|
|||
|
|||
![]()
dear fumei,
does this code also works with sub-directories or only the main directory? |
#9
|
|||
|
|||
![]()
Paul, Gerry
The add-in uses a scripting.filesystem object. Alysolymna, No Gerry's Dir example doesn't process sub-folders. The add-in does. |
#10
|
|||
|
|||
![]()
Thanks for your reply. do you have a link to download the add-in.
sorry for bothering you. |
#11
|
||||
|
||||
![]()
Greg already provided that in post #3 in this thread.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mass editing of hyperlinks | Michael137 | PowerPoint | 0 | 10-29-2012 02:44 AM |
![]() |
tdmag62 | Outlook | 1 | 11-30-2011 09:27 PM |
![]() |
Jamal NUMAN | Word | 2 | 07-08-2011 03:56 AM |
![]() |
daryl | Mail Merge | 1 | 03-23-2010 03:45 PM |
![]() |
dpool2002 | Outlook | 1 | 06-21-2006 02:11 PM |