I found the follow code from a old thread. My problem is that it open the correct document (word 2003)from the command button on the form(access 2003) but does not populate the word document. It has a 438 error. I do thot know if it aproblem with bookmards in word or acces not sending it. Any Idea appreciated. Also from what I read it was suggest bookmarks are NOT the way to go if if there are othe suggestion please to mak this work. The idea is to populate name phone, fax section etc from the current record to the word document, so it can be emailed to the section to arrange card.
-----------------------------------------------------------------
Private Sub Command155_Click()
On Error GoTo Err_Command155_Click
Dim objword As Word.Application
Set objword = CreateObject("Word.Application")
With objword
.Visible = True
.Documents.Open ("G:\OMR\MRM\_MARS\1. Management & Admin\Finance\swipecard.doc")
.ActiveDocument.Bookmarks("Lastname").Select
.Selection.Text = (CStr(Forms!Addresses!LastName))
.ActiveDocument.Bookmarks("Firstname").Select
.Selection.Text = (CStr(Forms!Addresses!FirstName))
' other field detail to be hear
End With
objword.ActiveDocument.PrintOut Background:=False
objword.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
objword.Quit
Set objword = Nothing
Exit Sub
Err_Command155_Click:
If Err.Number = 94 Then
objword.Selection.Text = ""
Resume Next
Else
MsgBox Err.Number & vbCr & Err.Description
End If
End Sub
Never give up never give in.
There are no short cuts to anything worth doing
-----------------------------------------------------------------
Private Sub Command155_Click()
On Error GoTo Err_Command155_Click
Dim objword As Word.Application
Set objword = CreateObject("Word.Application")
With objword
.Visible = True
.Documents.Open ("G:\OMR\MRM\_MARS\1. Management & Admin\Finance\swipecard.doc")
.ActiveDocument.Bookmarks("Lastname").Select
.Selection.Text = (CStr(Forms!Addresses!LastName))
.ActiveDocument.Bookmarks("Firstname").Select
.Selection.Text = (CStr(Forms!Addresses!FirstName))
' other field detail to be hear
End With
objword.ActiveDocument.PrintOut Background:=False
objword.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
objword.Quit
Set objword = Nothing
Exit Sub
Err_Command155_Click:
If Err.Number = 94 Then
objword.Selection.Text = ""
Resume Next
Else
MsgBox Err.Number & vbCr & Err.Description
End If
End Sub
Never give up never give in.
There are no short cuts to anything worth doing