ok for starters i am able to use mail merge for this this but want to use access to do it form me.
the problem i am having is when i run the event procedure in access i can not get the feilds to go to seperate areas ie name needs to go to three different places in the document.
I can get the bookmark part to work but not the ref to the bookmark
What should be the reference when doing this.
sample codeis
On Error GoTo MergeButton_Err
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Open ("C:\Circs\accessdocs\Request for Docs.doc")
'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("busname").Select
.Selection.Text = (CStr(Forms!jobs!busname))
.ActiveDocument.Bookmarks.Add Name:="busname", Range:=Selection.Range
.ActiveDocument.Bookmarks("buscon").Select
.Selection.Text = (CStr(Forms!jobs!buscon))
.ActiveDocument.Bookmarks.Add Name:="buscon", Range:=Selection.Range
.ActiveDocument.Bookmarks("busfax").Select
.Selection.Text = (CStr(Forms!jobs!busfax))
.ActiveDocument.Bookmarks.Add Name:="busfax", Range:=Selection.Range
.ActiveDocument.Bookmarks("busphone").Select
.Selection.Text = (CStr(Forms!jobs!busphone))
.ActiveDocument.Bookmarks.Add Name:="busphone", Range:=Selection.Range
.ActiveDocument.Bookmarks("busemail").Select
.Selection.Text = (CStr(Forms!jobs!busemail))
.ActiveDocument.Bookmarks.Add Name:="busemail", Range:=Selection.Range
.ActiveDocument.Bookmarks("cl").Select
.Selection.Text = (CStr(Forms!jobs!cl))
.ActiveDocument.Bookmarks.Add Name:="cl", Range:=Selection.Range
.ActiveDocument.Bookmarks("clnumb").Select
.Selection.Text = (CStr(Forms!jobs!clnumb))
.ActiveDocument.Bookmarks.Add Name:="clnumb", Range:=Selection.Range
.ActiveDocument.Bookmarks("dofinj").Select
.Selection.Text = (CStr(Forms!jobs!dofinj))
.ActiveDocument.Bookmarks.Add Name:="dofinj", Range:=Selection.Range
.ActiveDocument.Bookmarks("inscon").Select
.Selection.Text = (CStr(Forms!jobs!inscon))
.ActiveDocument.Bookmarks.Add Name:="inscon", Range:=Selection.Range
.ActiveDocument.Bookmarks("inscomp").Select
.Selection.Text = (CStr(Forms!jobs!inscomp))
.ActiveDocument.Bookmarks.Add Name:="inscomp", Range:=Selection.Range
End With
MergeButton_Err:
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.Number = 94 Then
MsgBox Err.Description
objWord.Selection.Text = ""
Resume Next
Else
MsgBox Err.Description
End If
Exit Sub
Chris
the problem i am having is when i run the event procedure in access i can not get the feilds to go to seperate areas ie name needs to go to three different places in the document.
I can get the bookmark part to work but not the ref to the bookmark
What should be the reference when doing this.
sample codeis
On Error GoTo MergeButton_Err
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Open ("C:\Circs\accessdocs\Request for Docs.doc")
'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("busname").Select
.Selection.Text = (CStr(Forms!jobs!busname))
.ActiveDocument.Bookmarks.Add Name:="busname", Range:=Selection.Range
.ActiveDocument.Bookmarks("buscon").Select
.Selection.Text = (CStr(Forms!jobs!buscon))
.ActiveDocument.Bookmarks.Add Name:="buscon", Range:=Selection.Range
.ActiveDocument.Bookmarks("busfax").Select
.Selection.Text = (CStr(Forms!jobs!busfax))
.ActiveDocument.Bookmarks.Add Name:="busfax", Range:=Selection.Range
.ActiveDocument.Bookmarks("busphone").Select
.Selection.Text = (CStr(Forms!jobs!busphone))
.ActiveDocument.Bookmarks.Add Name:="busphone", Range:=Selection.Range
.ActiveDocument.Bookmarks("busemail").Select
.Selection.Text = (CStr(Forms!jobs!busemail))
.ActiveDocument.Bookmarks.Add Name:="busemail", Range:=Selection.Range
.ActiveDocument.Bookmarks("cl").Select
.Selection.Text = (CStr(Forms!jobs!cl))
.ActiveDocument.Bookmarks.Add Name:="cl", Range:=Selection.Range
.ActiveDocument.Bookmarks("clnumb").Select
.Selection.Text = (CStr(Forms!jobs!clnumb))
.ActiveDocument.Bookmarks.Add Name:="clnumb", Range:=Selection.Range
.ActiveDocument.Bookmarks("dofinj").Select
.Selection.Text = (CStr(Forms!jobs!dofinj))
.ActiveDocument.Bookmarks.Add Name:="dofinj", Range:=Selection.Range
.ActiveDocument.Bookmarks("inscon").Select
.Selection.Text = (CStr(Forms!jobs!inscon))
.ActiveDocument.Bookmarks.Add Name:="inscon", Range:=Selection.Range
.ActiveDocument.Bookmarks("inscomp").Select
.Selection.Text = (CStr(Forms!jobs!inscomp))
.ActiveDocument.Bookmarks.Add Name:="inscomp", Range:=Selection.Range
End With
MergeButton_Err:
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.Number = 94 Then
MsgBox Err.Description
objWord.Selection.Text = ""
Resume Next
Else
MsgBox Err.Description
End If
Exit Sub
Chris