Access record to Word document

M

MSU Sptn2

I am using the following code in access to merge an access record into the
bookmarks of a word document:

Dim objWord As word.Application
Dim JobHolder As String
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Open ("Z:\ODDForms2.doc")

.ActiveDocument.Bookmarks("PIC").Select
If [Form_ODDAPP FORM].PIC <> "" Then
.Selection.Text = (CStr([Form_ODDAPP FORM].PIC))
Else
.Selection.Text = (CStr(""))
End If

.ActiveDocument.Bookmarks("Risk").Select
If [Form_ODDAPP FORM].[Risk No] <> "" Then
.Selection.Text = (CStr([Form_ODDAPP FORM].[Risk No]))
Else
.Selection.Text = (CStr(""))
End If

End With

As soon as Word opens, Access crashes. Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top