Saving HTML as Word Document

S

Steven Moschidis

I have found myself in a situation where I have to open an HTML file and
then save it as a word document and then do some work on it.
The bit that is troubling me is the actual opening and saving...
I am trying to do this using VB6 and this is the code I am using to open the
HTML file and save the .doc file.

Set docHTML = wrdApplication.Documents.Open("c:\test.htm")
docTranscript = wrdApplication.ActiveDocument.SaveAs("c:\test.doc",
wdFormatDocument)

Please note that I have to use Office 2000 (MS Word Obj Lib Ver 9) and that
the error I get with this code highlights SaveAs and says "Expected Function
or Variable"

I've been using VB6 for quite some time now (approx. 2 yrs), but never dealt
with office, so if I'm being extremely stupid then please forgive my
ignorance.
Thank you in advance for your assistance.

Steven Moschidis
 
D

Doug Robbins - Word MVP

Hi Steven,

Just guessing here, but probably you need to use

Set docTranscript = wrdApplication.ActiveDocument.SaveAs("c:\test.doc",
wdFormatDocument)

or try

wrdApplication.ActiveDocument.SaveAs "c:\test.doc", wdFormatDocument
Set docTranscript = wrdApplication.ActiveDocument

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
S

Steven Moschidis

Thank you for your reply!
I tried both of them and unfortunately none of them worked. The first one
gave me the same error and the second one gave me an error basically saying:
Object Variable or With Block variable not set. The error comes up when the
wrdApplicaiton.ActiveDocument.SaveAs "c:\test.doc", wdFormatDocument line is
executed. (I personally believe that for some reason it doesnt like
wdFormatDocument). Anyway I can't put my finger on it.
The code around this opening/saving bit is just the declaration of the
variables used and afterwards the closing of those variables so there's
nothing complicated messing things up. What I am wondering is if there is
some obscure reference (apart from the word obj lib I mentioned) that I need
to include...
Thank you for your help!

Steven Moschidis
 
D

Doug Robbins - Word MVP

Hi Steven,

As wdFormatDocument is the default, try running without it.

You could also try

docHTML.SaveAs("c:\test.doc")

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
S

Steven Moschidis

Never mind! It turns out I was just being stupid. It is now working. Thank
you for your input!
:)

Steven Moschidis
 

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