You will need to add a reference to word (assuming you have this on your machine, otherwise it will become very complicated)
Then simply
'create a new instance of word, and a placeholder for the document
Dim wrdApp As New Word.Application
Dim wrdDoc As Word.Document
'open the document you want
Set wrdDoc = wrdApp.Documents.Open("D:\MyDoc.doc", True)
'save the document specifying the format
wrdDoc.SaveAs "c:\mydoc.txt", wdFormatText
'dont forget to tidy up
wrdDoc.Close
hmckillop & rdavis: Thank you both very much for your help! I got "error 5154, You cannot Save a template file to non-template format". Maybe this word documnet is special. Please help. Thanks again!
Rob: It's a data source file used to do mail merge. Basically I want to count how many records in the file --- I can do it for a text file. Is there any way to count how many lines or how many new lines in this file? Thanks!
Yes, Rob. The same error message. But it worded when I moved this to another machine. I guess this has something to do with Word setting on this computer. Thanks!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.