Bookmarks in word

  • Thread starter Thread starter LJG
  • Start date Start date
L

LJG

Can anyone tell me how I can not get an error using bookmarks in a word
document if the field has no data

TIA

Les
 
Can anyone tell me how I can not get an error using bookmarks in a word
document if the field has no data

TIA

Les

You have posted this message to the wrong newsgroup.
The access in this groups name refers to Microsoft Access, a database
program.
Please repost to the correct newsgroup for the Word program you are
using. I would suggest you include your Windows and Office version
number in the message.
 
Sorry, should have made it clearer

I am sending data from a access form to merge to a word document using
bookmarks for the field placement. The issue I have is if any field have
null values it causes an error and I would like to ignore the field if the
value is blank.

This is my code:

Private Sub Command489_Click()
Dim strLetter As String
strLetter = "C:\database\Standard appt letter.doc"

Dim objword As Word.Application
Set objword = CreateObject("Word.Application")
With objword
.Visible = False
.Documents.Open (strLetter)
.ActiveDocument.Bookmarks("Company").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![Company]))
.ActiveDocument.Bookmarks("Address1").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![address1]))
.ActiveDocument.Bookmarks("Address2").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![address2]))
.ActiveDocument.Bookmarks("City").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![City]))
.ActiveDocument.Bookmarks("County").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![county]))
.ActiveDocument.Bookmarks("postcode").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![postcode]))
.ActiveDocument.Bookmarks("contact_first").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![contact_first]))
.Selection.Text =
(CStr(Forms![frmCustomers_edit]![frmFollowUpNotesMain]![df2]))
.ActiveDocument.Bookmarks("tm1").Select
.Selection.Text =
(CStr(Forms![frmCustomers_edit]![frmFollowUpNotesMain]![tm1]))
.ActiveDocument.Bookmarks("txtMAM").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![txtmam]))
.ActiveDocument.Bookmarks("Text438").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![Text438]))
.ActiveDocument.Bookmarks("txtemail").Select
.Selection.Text = (CStr(Forms![frmCustomers_edit]![txtemail]))
End With

objword.ActiveDocument.PrintOut Background:=True
objword.ActiveDocument.PrintOut , , , , , , , 1
objword.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
objword.Quit
Set objword = Nothing
End Sub
 
Back
Top