Expand|Select|Wrap|Line Numbers
- Private Sub OpenWindows_Click()
- Dim Word As Object
- Dim doc As Word.Document
- Dim prps As Object
- Dim strLastName As String
- Dim lngContactID As Long
- Dim strTitle As String
- Dim strPrompt As String
- Dim Selection As Selection
- lngContactID = Nz(Me![ID])
- If lngContactID = 0 Then
- strPrompt = "No contact selected"
- strTitle = "Problem"
- MsgBox strPrompt, vbOKOnly + vbExclamation, strTitle
- Else
- strLastName = Nz(Me![LastName])
- End If
- Set Word = CreateObject("Word.Application")
- Word.Documents.Open CurrentProject.Path & "\test.dot"
- Set prps = doc.CustomDocumentProperties
- prps.Item("LastName").Value = strLastName
- With Word
- .Selection.WholeStory
- .Selection.Fields.Update
- .Selection.HomeKey unit:=wdStory
- End With
- Word.Visible = True
- End Sub
"Run-time error '91':
Object Variable or With block variable not set.
When I debug it, line 23 shows the error.
Any guidance would be much appreciated.