GetObject and CreateObject fail to create word.application

G

Guest

Hi,
I'm wondering whether anyone can help with this.
I have a function that accepts the name of a word template, strTemplate and
opens a word document based on this template. The following is the part of
the code which is failing. When the function is called, a Word window is
created but no new word document is created. This function works perfectly
on two computers but I can't get it to work at all on a third computer. I
suspect it is a references problem but can't seem to fix this so I'm
wondering if I am barking up the wrong tree. The two MsgBox statements
below produce the error description "ActiveX Component can't create object".

Thank you in advance.

Dim WordObj1 As Word.Application
Dim WordDoc As Word.Document

Set dbDatabase1 = CurrentDb()
strPath = Form_frm_NSWGS!LetterTemplatePath

Set WordObj1 = GetObject(, "word.application")
MsgBox (Err.Description)
If Err.Number <> 0 Then
Set WordObj1 = CreateObject("word.application")
MsgBox (Err.Description)
End If
WordObj1.Visible = True
WordObj1.Documents.Add Template:=strPath & strTemplate & ".dot",
NewTemplate:=False
 
G

Guest

sorry everyone.
I have discovered this code is actually working. I had forgotten to add a
"\" to the end of strPath in the table storing the Letter template path.
Feeling very stupid!
Anna
 

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