Word Documents no longer open from access form

Cpowell

Registered User.
Local time
Today, 08:16
Joined
May 20, 2009
Messages
10
Hi,

I use a database to open word documents and populate them with information. As of this morning that no longer works. Here is my code ( there are a dozen like this and none work this is just the shortest):

Private Sub Command16_Click()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim strSQL As String
Dim strReportsTo As String
Dim fullpath As String
On Error Resume Next
Set appWord = GetObject(, "Word.application")

With appWord

Set doc = .Documents.Add(Template:="H:\Forms\Form1.dot", newtemplate:=False, Documenttype:=0)

With doc
.FormFields("number").Result = (Me!Number) & ""
.FormFields("Date").Result = (Me!Date1) & ""
.FormFields("LastName").Result = (Me!LastName) & ""
.FormFields("FirstName").Result = (Me!FirstName) & ""
.FormFields("Client").Result = (Me!Client) & ""
.FormFields("Employee").Result = (Me!Employee) & ""

End With
.Visible = True
.Activate
End With
Set rst = Nothing
Set doc = Nothing
Set appWord = Nothing


End Sub

It stopped working while I was working on making a new databse this morning. It works fine when I borrow someone else's login, but no longer functions for me.

Thanks for your help.
 
i don't know much about this, but did your network permissions change?
 
I've had issues before with the line: Dim appWord As Word.Application

Instead try:

Dim appWord as Object
Set appWord = CreateObject("Word.Application")

...also remove your existing Set appWord line. Leave the rest of your code as it is and see if it now runs.

Dim-ing applications seems to cause sporadic issues. Have you downloaded a service pack or update? I think the specific version of Access makes a difference. Anyhow, in my experience Access can either work with my method or work with either method, but it never works with your current method and NOT my method, so my method should be more robust.

Hope it helps!
 
Kafrin,

I too, use the OBJECT method when opening excel and word, but not with outlook. good thing you pointed this out. that'll probably solve it.
 

Users who are viewing this thread

Back
Top Bottom