Previous Thread

6/30/2006 9:54:43 AM    Re: Bookmarks in word
On Fri, 30 Jun 2006 17:30:16 +0100, LJG wrote: 
 
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. 
 
-- 
 
Fred 
 
Please respond only to this newsgroup. 
 
I do not reply to personal e-mail



6/30/2006 5:30:16 PM    Bookmarks in word
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

7/1/2006 10:47:44 AM    Re: Bookmarks in word
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 
 
"fredg" <fgutkind@example.invalid> wrote in message 
 
news:cojxbb7eucmj.1jpsci8t09u1k.dlg@40tude.net...