Why does this code fail (1 Viewer)

bunker

New member
Local time
Today, 14:36
Joined
Mar 12, 2002
Messages
5
I am running A2K and the error I get states "File name or class name not found during Automation Operation . "

Private Sub Open_Merge_WordDoc(strPath As String)

Dim strDocument As String


Dim objWord As Word.Document
Set objWord = GetObject(" & strPath & ",
"Word.Document")

'*** 'iT 'FAILS 'RIGHT 'HERE 'wHEN '''' 'gEToBJECT IS CALLED ***
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the
personnel database.
objWord.MailMerge.OpenDataSource _
Name:="C:\GHN\GHNWordData.mdb", _
LinkToSource:=True, _
Connection:="QUERY qryDailyLetters"
' Execute the mail merge.
objWord.MailMerge.Execute

end sub


****************

The string strPAth works fine when I use the shell command

shell "winword.exe " Chr(34) & strPath
 

Alexandre

Registered User.
Local time
Today, 20:36
Joined
Feb 22, 2001
Messages
794
Bunker,

If your goal was to surround the strPAth string with quotes, you should try:

"""" & strPath & """"

If not, remove the quotes and &.

Alex
 

Users who are viewing this thread

Top Bottom