opening word from a form

  • Thread starter Thread starter woody
  • Start date Start date
W

woody

i have an access database, it opens with a menu form, one
of the options it to open up a letter from the form.

i set a reference to the word dll.
use the following code which works in vb6.

but here i get activex unable to create object.

i have no idea what i am doing wrong.

please help.

thanks

Woody

Dim wordApp As Object

wordApp = GetObject(, "Word.Application")
If Err <> 0 Then
wordApp = CreateObject(Word.Application)
End If

wordApp.Documents.Open FileName:=app.Path & "Letter.doc"

wordApp.Quit
Set wordApp = Nothing
 
I would try:

Set WordApp = CreateObject("Word.Application")

You are missing quotes in your example. I assume you also are using late
binding?

In addition, I have a ready made sampel for word merge for ms-access. It
allows you to word enable any ms-access form with ONE line of code. It will
launch word, and only merge the current record you are looking at.

There is some sample data. It also eliminates several know bugs. Try my
working sample, and the "one line" to enable any form is real nice. Also
read my notes on how to make a reliable word merge that does not break...

Check out:
http://www.attcanada.net/~kallal.msn/msaccess/msaccess.htm
 
Back
Top