using word to open an html file and save it as .doc 
Author Message
 using word to open an html file and save it as .doc

Hello,

I want to open an html file with Word and then save the html file as a doc
file.  Here is what I tried (that fails):

set myWord = createobject("Word.Application")
myWord.Documents.Open("c:\test.html")
myWord.Visible = 0
myWord.Documents(0).SaveAs("c:\test.doc")
myWord.Quit

Can anyone tell me what is wrong?

Thanks,
Scott



Tue, 17 Jun 2003 06:38:47 GMT  
 using word to open an html file and save it as .doc
Hi Scott,

The problem is in the SaveAs command. It's not sufficient to use a different
filename extension, that simply saves an HTML format file with a doc
extension - not a lot of use! You actually have to tell Word to save in a
different file format.

Try this instead

Set myWord = createobject("Word.Application")
Set myDoc = myWord.Documents.Open("c:\test.html")
myWord.Visible = 0
myDoc.SaveAs FileName:="c:\test.doc", FileFormat:=wdFormatDocument
myWord.Quit

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> Hello,

> I want to open an html file with Word and then save the html file as a doc
> file.  Here is what I tried (that fails):

> set myWord = createobject("Word.Application")
> myWord.Documents.Open("c:\test.html")
> myWord.Visible = 0
> myWord.Documents(0).SaveAs("c:\test.doc")
> myWord.Quit

> Can anyone tell me what is wrong?

> Thanks,
> Scott



Tue, 17 Jun 2003 10:04:12 GMT  
 using word to open an html file and save it as .doc
Thanks!  That works great!

Scott


Quote:
> Hi Scott,

> The problem is in the SaveAs command. It's not sufficient to use a
different
> filename extension, that simply saves an HTML format file with a doc
> extension - not a lot of use! You actually have to tell Word to save in a
> different file format.

> Try this instead

> Set myWord = createobject("Word.Application")
> Set myDoc = myWord.Documents.Open("c:\test.html")
> myWord.Visible = 0
> myDoc.SaveAs FileName:="c:\test.doc", FileFormat:=wdFormatDocument
> myWord.Quit

> --
> Regards
> Jonathan West - Word MVP
> MultiLinker - Automated generation of hyperlinks in Word
> Conversion to PDF & HTML
> http://www.multilinker.com
> Word FAQs at http://www.multilinker.com/wordfaq
> Please post any follow-up in the newsgroup. I do not reply to Word
questions
> by email



> > Hello,

> > I want to open an html file with Word and then save the html file as a
doc
> > file.  Here is what I tried (that fails):

> > set myWord = createobject("Word.Application")
> > myWord.Documents.Open("c:\test.html")
> > myWord.Visible = 0
> > myWord.Documents(0).SaveAs("c:\test.doc")
> > myWord.Quit

> > Can anyone tell me what is wrong?

> > Thanks,
> > Scott



Wed, 18 Jun 2003 06:56:03 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to change or save a MS Word file (*.doc) to a *.html file in VBScript

2. Word Doc saved as HTML

3. Saving a Word doc as HTML

4. Printing multiple Word doc files without opening each in word

5. Word HTML file to .doc file.

6. Word HTML file to .doc file.

7. Problem Opening large HTML file in Word using VBA

8. Problem Opening large HTML file in Word using VBA

9. Opening a word doc in part of an html page

10. Open and Save MS.Word Doc from VB

11. FileFormat value for saving DOC files as HTML [WD97]

12. File open script within HTML doc

 

 
Powered by phpBB® Forum Software