Access VBA

C

Carlos Santos

hello, when i call from access a word document and i close it. it retuns a
message "An unexpected error has occurred". Anyone can tell me how i
eliminate that.
Regards
Carlos
 
C

Carlos Santos

to open word doc i use:

Command24.HyperlinkAddress = recordsetx.Fields(0)

to close word doc i don't have any code
 
D

Douglas J. Steele

If you open the Word document normally (i.e.: not from within Access) and
close it, does it close without error?
 
C

Carlos Santos

yes. it close without error

Douglas J. Steele said:
If you open the Word document normally (i.e.: not from within Access) and
close it, does it close without error?
 
D

David C. Holley

Douglas -

So what are the advantages of using this method, as opposed to creating
an instance of Word using CreateObject, opening the file and then
displaying it? I'm assuming that 1 of the advantages is that Access will
look at the file extension and open the correct application? Are there
others?
 
D

Douglas J. Steele

Using a hyperlink lets you open the document in its registered program, and
nothing else.

Opening an instance of Word using CreateObject lets you use automation on
the document.

Which is better depends on what you're doing.
 
D

Douglas J. Steele

Do other documents have this same problem if you open them from within
Access and then close them?
 
D

Douglas J. Steele

Just realized this isn't strictly true.

If you open the document using the hyperlink, you can always get a reference
to that instance of Word using GetObject, and then use automation that way.
 
Top