Batch text replacement in DOC files.

  • Thread starter Thread starter Jan2004
  • Start date Start date
J

Jan2004

I'm looking for tool which can make batch text replacement in .DOC files.
Simply: I want to replece the same text line in 250 files by anoher text
line. Thanks for help.
 
Can't be done --- .doc files are binary.

Save them out as .rtf to do this sort of thing.

William
 
I'm looking for tool which can make batch text replacement in .DOC files.
Simply: I want to replece the same text line in 250 files by anoher text
line. Thanks for help.

I've used gsar from <http://home.online.no/~tjaberg/> to do replacements
of binary data in MS Word .doc files. Operating on these files does
require a binary capable replacer which gsar is.
 
Than you all for help. William, do you know any tool, which can batch open
DOC files and save them in .RTF format (in one process) ? Or do you know
exact converter, which can make that job ?

Jan
 
Than you all for help. William, do you know any tool, which can batch open
DOC files and save them in .RTF format (in one process) ? Or do you know
exact converter, which can make that job ?

It's something which can be done via macros. That's why you should ask
such questions in a Winword related group. Anyhow, I do it with the
following code:

Sub SaveAsRtf()
Dim sFName As String
sFName = ActiveDocument.FullName
If ActiveDocument.SaveFormat = wdFormatDocument And _
Right(sFName, 4) = ".doc" Then
ActiveDocument.SaveAs FileName:=Left(sFName, Len(sFName) - 4) & _
".rtf", FileFormat:=wdFormatRTF
End If
ActiveDocument.Close
If Application.Documents.Count = 0 Then
Application.Quit
End If
End Sub

Using the command line parameter /m for Winword you could either create
a 'Shell\Convert' shortcut for *.doc files (inside the registry):

"[PTW]\winword.exe" /mSaveAsRtf "%1"

or make a touch-to-Rtf batch:

for %%i in (*.doc) do [PTW]\winword.exe /mSaveAsRtf "%%i"

Replace [PTW] with the path to your Winword executable in both cases. ;-)

BeAr
 
I'm looking for tool which can make batch text replacement in .DOC files.
Simply: I want to replece the same text line in 250 files by anoher text
line. Thanks for help.

Sorry, I didn't see that your original request wasn't solved, yet.
You could do it likewise to the *.rtf conversation:

Sub FindRepl()
Dim sFind, sRepl As String
sFind = "Enter your FIND text here"
sRepl = "Enter your REPLACE text here"
Selection.Find.Execute FindText:=sFind, ReplaceWith:=sRepl, _
Replace:=wdReplaceAll
ActiveDocument.Close SaveChanges:=wdSaveChanges
If Application.Documents.Count = 0 Then
Application.Quit
End If
End Sub

You have to hard-code the find and replace texts inside the macro.
But that shouldn't matter in your case. If you need other options
(like MatchCase or MatchWildcards), you can simply add them to
the code.

Again: The request would have been better placed inside a Winword
related group...

BeAr
 
Back
Top