Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Code to convert many *.doc files to *.txt

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob - 03 Nov 2006 06:06 GMT
Hi,

I have over 500 Word doc files I need to convert to text format so that I
can import them to a database program.   I plan to open 20 or so files at a
time and I would like a macro to save each file by the same name as the
original, but with the txt extension, overiding any warning message/s that
format will be lost, etc.

I'm guessing I need to do this in Word, but if there's a better solution to
do this than I'm open to any suggestions.  (If anyone knows how to create
something whereby I can  import the files to the program called ZionWorx,
which is a song display program using multimedia such as a data projector,
I'd love to hear from you too!)

Rob
Jezebel - 03 Nov 2006 06:30 GMT
> Hi,
>
[quoted text clipped - 11 lines]
>
> Rob
Jezebel - 03 Nov 2006 06:42 GMT
If all the files are in the same folder --

   Dim pOldFile As String
   Dim pNewFile As String
   Dim pDoc As Word.Document

   Const pFolder As String = "..[folder]\"

   Application.DisplayAlerts = wdAlertsNone
   pOldFile = Dir(pFolder & "*.doc")
   Do Until Len(pOldFile) = 0
       Set pDoc = Documents.Open(FileName:=pFolder & pOldFile)
       pNewFile = Left(pDoc.FullName, Len(pDoc.FullName) - 3) & "txt"
       pDoc.SaveAs FileName:=pNewFile, fileformat:=wdFormatText
       pDoc.Close savechanges:=False
       pOldFile = Dir()
   Loop
   Application.DisplayAlerts = wdAlertsMessageBox

> Hi,
>
[quoted text clipped - 11 lines]
>
> Rob
Rob - 04 Nov 2006 00:07 GMT
Thanks Jezebel, but Jonathon's solution to use the Batch convertor seems an
easy solution.
I did try to run the code you submitted, but I'm a bit of a novice and I
think I probably needed to do some more work with that.....like put the path
and name to the folder, etc., somewhere in that code??

Rob

> If all the files are in the same folder --
>
[quoted text clipped - 30 lines]
>>
>> Rob
Jezebel - 04 Nov 2006 03:10 GMT
Well yes: put the folder name in this line

Const pFolder As String = "..[folder]\"

> Thanks Jezebel, but Jonathon's solution to use the Batch convertor seems
> an easy solution.
[quoted text clipped - 38 lines]
>>>
>>> Rob
Jonathan West - 03 Nov 2006 11:08 GMT
Hi Rob,

If you did a full install of Office, you should have the Batch Conversion
Wizard awailable to you. This does exactly what you are trying to achieve.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi,
>
[quoted text clipped - 11 lines]
>
> Rob
Rob - 04 Nov 2006 00:11 GMT
Thanks Jonathon.  I didn't know about that wizard and it worked perfectly.

Rob

> Hi Rob,
>
[quoted text clipped - 16 lines]
>>
>> Rob
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.