Batch Conversion

R

Ric

I frequently need to convert large batches of word documents to plain text
files. The wizard included with word isn't really up to the job becuase it
can only convert within one folder. I wonder if anyone could give me an
example of code that would perform this conversion recursively?

Any help would be cool!

Thanks,
Ric.
 
H

Harold Kless[MSFT}

Hi Ric,
This article provides a code sample that recursively move thru folders.
You'll need to add your code that opens each document and saves as a text
file.
185601 HOW TO: Recursively Search Directories by Using FileSystemObject
http://support.microsoft.com/?id=185601

Harold Kless, MCSD
Support Professional
Microsoft Technical Support for Business Applications
(e-mail address removed)

--


This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
J

Jonathan West

Hi Ric

This will do the needful

Sub ConvertRecursive()
Dim i As Long
Dim strSaveFile As String
With Application.FileSearch
.FileName = "*.doc"
.LookIn = "C:\My special folder"
.SearchSubFolders = True
.Execute
If .FoundFiles.Count > 0 Then
For i = 1 To .FoundFiles.Count
strSaveFile = .FoundFiles(i)
strSaveFile = Left$(strSaveFile, InStrRev(strSaveFile, ".")) &
"txt"
Documents.Open FileName:=.FoundFiles(i)
ActiveDocument.SaveAs FileName:=strSaveFile, _
FileFormat:=wdFormatText
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Next i
End If
End With

End Sub

Change the name of the folder in the Lookin property as appropriate. If you
want the user to be able to select the folder to be searched, then this
article describes how you can let the user browse to and select a folder

How to allow the user to browse to and select a folder
http://www.mvps.org/word/FAQs/MacrosVBA/BrowsDialog.htm


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com



Ric said:
Anyone?


Harold Kless[MSFT} said:
Hi Ric,
This article provides a code sample that recursively move thru folders.
You'll need to add your code that opens each document and saves as a text
file.
185601 HOW TO: Recursively Search Directories by Using FileSystemObject
http://support.microsoft.com/?id=185601

Harold Kless, MCSD
Support Professional
Microsoft Technical Support for Business Applications
(e-mail address removed)

--


This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
R

Ric

Marvellous - works a treat! Thanks a lot :)

Jonathan West said:
Hi Ric

This will do the needful

Sub ConvertRecursive()
Dim i As Long
Dim strSaveFile As String
With Application.FileSearch
.FileName = "*.doc"
.LookIn = "C:\My special folder"
.SearchSubFolders = True
.Execute
If .FoundFiles.Count > 0 Then
For i = 1 To .FoundFiles.Count
strSaveFile = .FoundFiles(i)
strSaveFile = Left$(strSaveFile, InStrRev(strSaveFile, ".")) &
"txt"
Documents.Open FileName:=.FoundFiles(i)
ActiveDocument.SaveAs FileName:=strSaveFile, _
FileFormat:=wdFormatText
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Next i
End If
End With

End Sub

Change the name of the folder in the Lookin property as appropriate. If you
want the user to be able to select the folder to be searched, then this
article describes how you can let the user browse to and select a folder

How to allow the user to browse to and select a folder
http://www.mvps.org/word/FAQs/MacrosVBA/BrowsDialog.htm


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com



Ric said:
Anyone?


Harold Kless[MSFT} said:
Hi Ric,
This article provides a code sample that recursively move thru folders.
You'll need to add your code that opens each document and saves as a text
file.
185601 HOW TO: Recursively Search Directories by Using FileSystemObject
http://support.microsoft.com/?id=185601

Harold Kless, MCSD
Support Professional
Microsoft Technical Support for Business Applications
(e-mail address removed)

--


This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top