Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access to word

Status
Not open for further replies.

toffa

Programmer
Aug 24, 2004
77
AU
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top