M
michirure
I have the following codes which open a word template and fill it with data
from current record in Access.
Set oApp = CreateObject("Word.Application")
WordTemplate = "D:\Temp\Merge Letter.doc"
With oApp
.Visible = True
.Documents.Add (WordTemplate)
.ActiveDocument.Bookmarks("Account").Select
.Selection.Text = (CStr(Me.[Account]))
.ActiveDocument.Bookmarks("Acct_Phone").Select
.Selection.Text = (CStr(Me.[Acct_Phone]))
.Activate
End With
The codes work well, but now another problem comes up. In my access form,
some fileds are blank because I don't have certain info about the client eg.
phone number.
When I tried to use the If...then...else function, I got the error
msg "Object required"
.ActiveDocument.Bookmarks("Acct_Phone").Select
If Me.[Acct_Phone] Is Null Then
.Selection.Text = ""
Else
.Selection.Text = (CStr(Me.[Acct_Phone]))
End If
Please help. Thanks
from current record in Access.
Set oApp = CreateObject("Word.Application")
WordTemplate = "D:\Temp\Merge Letter.doc"
With oApp
.Visible = True
.Documents.Add (WordTemplate)
.ActiveDocument.Bookmarks("Account").Select
.Selection.Text = (CStr(Me.[Account]))
.ActiveDocument.Bookmarks("Acct_Phone").Select
.Selection.Text = (CStr(Me.[Acct_Phone]))
.Activate
End With
The codes work well, but now another problem comes up. In my access form,
some fileds are blank because I don't have certain info about the client eg.
phone number.
When I tried to use the If...then...else function, I got the error
msg "Object required"
.ActiveDocument.Bookmarks("Acct_Phone").Select
If Me.[Acct_Phone] Is Null Then
.Selection.Text = ""
Else
.Selection.Text = (CStr(Me.[Acct_Phone]))
End If
Please help. Thanks