Thanks- Will give #2 a try. I did confirm reference was checked, and then unchecked and checked it again, but did not re-boot between the two. Will try Monday. (I'm not sure WHAT dll it wants. As far as I can tell the rest of my VBA code in the app is running (at least I didn't get other strange results). My concern is that we received some "patch" that is interfering.....)
I am NOT familiar with the Word Object model and have not ventured into that territory other than this little button. We are using the sub to launch pre-set up Word DOTs and sending client's addresses and a few other basic info into a series of DOTs. None of the DOTs require calculations. (And I don't want to spark any new ideas- the users come up with enough on their own :) !!!
Thanks-
I thought I had inserted my code- oops. Here it is:
=========
Private Sub cmdMergeLetter_Click()
' open a Word DOT and start a mail merge; DOT is already set up as mailmerge
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
âfails below on getobject() but strFilePath is filled appropriately
Set objWord = GetObject(strFilePath, "Word.document")â fails on getobject()
' make word visible
objWord.Application.Visible = True
' execute the mail merge
objWord.MailMerge.Execute
objWord.Close
End Sub
|