Word Error using VB Editor to Open document

T

Tom G.

When I type in the following commands in the Intermediate window, I get a
Word runtime error when I run the third line.

activedocument.SaveAs "C:\test.doc"
activedocument.Close
activedocument.Open "C:\test.doc"

The reason why I did this test is because an application that I wrote is not
working correctly on a client's machine. I narrowed it down to the vb code
that opens a document in Word.

Any suggestions why this may be happening? Any help would be greatly
appreciated. Thanks.
 
S

Steve Lang

Hi Tom,

Open isn't part of the ActiveDocument object. Change the line to
Documents.Open and see what happens.

HTH and have a great day!

Steve
 
T

Tom G.

I am sorry. That was mistyped. I only wish that it was a typo error. I
meant to say:

ActiveDocument.SaveAs "C:\test.doc"
ActiveDocument.Close
Documents.Open "C:\test.doc"

This is the code that caused the error, not the original code that I posted.

Thank you for bringing that to my attention Steve.
 
S

Steve Lang

Not specifically, but I was musing on whether having extensions viewable on
one computer and not another would impact the function. Upon further
inspection, I realize it does not.

Steve
 

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