document.SaveAs crashes application

C

cas4

I'm automating Word in a VB6 application. I'm opening the word document, makeing changes, then calling the document's SaveAs command. I get a Word error message (that I cannot trap using an "on error goto" statement), and the vb app crashes and quits with Word still residing in Memory. I'm compiliing the app on a machine with OfficeXP and running it on a machine with Office2k, but the SaveAs command is backwards compatible, isn't it? Below is the code I'm using to open and save the document, if anyone has had a problem with this command, please let me know. Thanks!

===========================================
Set Wordapp = New Word.Application
Set doc = Wordapp.Documents.Add(filename)
..
..
'modify the doc code
..
..
doc.SaveAs newfilename <- Word crashes when this line is executed
 
R

RWN

The Document.Add(filename) shouldn't work (I'd expect the bomb here(?))
The statement simply adds a new document. The parameters (all optional
BTW) that it takes are things like the template name to base the new
document on (if omitted it uses the Normal) template. (See the Word VBA
help).
You'd have to use Document.Open(filename)

Perhaps I've misunderstood or I'm not as smart as I thought I was (known
to happen)<G>.
--
Regards;
Rob

Please reply to the NG, I'm already up to my eyeballs in Nigerian/South
African get rich letters
as well as "Microsoft Critical Updates" et al.
 

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