Here is code to open the linked Word docs:
Private Sub cmdOpenWordDocs_Click()
'Created by Helen Feddema 2-Aug-2009
'Last modified by Helen Feddema 2-Aug-2009
On Error GoTo ErrorHandler
Set appWord = GetObject(, "Word.Application")
appWord.Visible = True
'Set up recordset of word docs for this contact
lngContactID = Nz(Me![ContactID])
If lngContactID = 0 Then
GoTo ErrorHandlerExit
Else
strRecordSource = "tblWordDocs"
strQuery = "qryTemp"
Set dbs = CurrentDb
strSQL = "SELECT * FROM " & strRecordSource & " WHERE " _
& "[ContactID] = " & lngContactID & ";"
Debug.Print "SQL for " & strQuery & ": " & strSQL
lngCount = CreateAndTestQuery(strQuery, strSQL)
Debug.Print "No. of items found: " & lngCount
If lngCount = 0 Then
strPrompt = "No records found; canceling"
strTitle = "Canceling"
MsgBox strPrompt, vbOKOnly + vbCritical, strTitle
GoTo ErrorHandlerExit
Else
Set rst = dbs.OpenRecordset(strQuery)
Do While Not rst.EOF
strWordDocNameAndPath = rst![WordDoc]
Set doc = _
appWord.Documents.Open(FileName:=strWordDocNameAndPath, _
ReadOnly:=True)
rst.MoveNext
Loop
End If
rst.Close
End If
ErrorHandlerExit:
Set appWord = Nothing
Exit Sub
ErrorHandler:
If Err = 429 Then
'Word is not running; open Word with CreateObject
Set appWord = CreateObject("Word.Application")
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Description: " _
& Err.Description
Resume ErrorHandlerExit
End If
End Sub
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57:





by: Helen_FeddemaPosted on 2009-08-02 at 08:58:39ID: 24999212
I would suggest just storing the file name and path for the Word doc (much less bloat then storing the doc as an OLE object), then writing VBA code to open it. Here is code for selecting a Word doc and storing its name and path in a field in a table (tblWordDocs) that is linked to tblContacts by ContactID:
Select allOpen in new window