I apologize for the multiple threads! I'm new to this forum and used to
one
that is fragmented.
So so I understand correctly that I can create an Object for Word, and
totally remove any reference to Word? Can I expect GetObject to work
against
the dimmed Word.Object when it isn't currently working against the dimmed
Word.Document?
I am not referencing any other Word constants anywhere else. At the
moment
both users have Word 2K. It is likely that my next project will include
users that have Work 2003, so I want to make this work in both arenas if
possible.
Thank you again,
--
Loralee
:
Hold on. Since you've started another thread (seldom a good idea when
you've
got an active one going), I would suspect that you're running into
problems
with your References collection, since you've got users with different
versions of Word.
Try removing the reference you have to Word, and changing
Dim objWord As Word.Document
to
Dim objWord As Object
If you're using any intrinsic Word constants (they'll all start "wd"),
you'll need to get the values of those constants and define them in your
code once you've removed the reference.
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
I'll give that a try- but it doesn't appear that the call to the
common
dialog that is causing the problem. In fact, the common dialog
launches
and
takes user's selection as strFilePath.
It is the line GetObject that is highlighted. Is that not a VBA
Function
call?
--
Loralee
:
Scrap the Common Dialog. Use the API approach demonstrated in
http://www.mvps.org/access/api/api0001.htm at "The Access Web".
Far more reliable...
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
In the area I cut out (for clairity). When I step-through the file
name
is
passing fine. The WHOLE sub is:
Private Sub cmdMergeLetter_Click()
' this is an attempt to open a Word document and start a mail
merge
Dim strFilePath As String
Dim objWord As Word.Document
Dim strPatientID As String ' use to link to patient
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
Dim strSQLMerge As String
strPatientID = Forms!frmpatientdata.txtPatientID
strSELECT = "SELECT tblPatient.[PatientID],
tblPatient.[PtFirstName],
tblPatient.[PtLastName], tblPatient.[PtBD], tblCity.[City],
tblPatient.[PtAddress], tblPatient.[PtZip], tblReferral.[ReferBy]"
strFROM = " FROM (tblCity INNER JOIN tblPatient ON tblCity.[CityID]
=
tblPatient.[PtCityFK]) INNER JOIN tblReferral ON
tblPatient.[PatientID]
=
tblReferral.[PtFK]"
strWHERE = " WHERE ((([PatientID])= " & strPatientID & "))"
strSQLMerge = strSELECT & strFROM & strWHERE
CurrentDb.QueryDefs("qrymailmerge").SQL = strSQLMerge
Me.cmdlg.DialogTitle = "Choose File Name and Location"
Me.cmdlg.ShowOpen
strFilePath = Me.cmdlg.FileName
Set objWord = GetObject(strFilePath, "Word.document")
' make word visible
objWord.Application.Visible = True
' execute the mail merge
objWord.MailMerge.Execute
objWord.Close
--
Loralee
:
Where does strFilePath get set?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
My Access app which ran FINE until yesterday is now throwing a
"missing
DLL"
error. The code that is now failinig is in a button that uses
the
common
dialog control and opens Word to complete mailmerge execution.
It
fails
at
getobject().
See below.
1) Does anyone know of another way to get to Word from Access?
2) Has this recently happened to anyone else?
====================
Dim strFilePath As String
Dim objWord As Word.Document
Dim strPatientID As String ' use to link to patient
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
Dim strSQLMerge As String
'i removed the SQL concantenation code as error not there
CurrentDb.QueryDefs("qrymailmerge").SQL = strSQLMerge
Set objWord = GetObject(strFilePath, "Word.document") 'fails here
' make word visible
objWord.Application.Visible = True
' execute the mail merge
objWord.MailMerge.Execute
objWord.Close
Thanks!