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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Current Record to Word

Status
Not open for further replies.

assets

Technical User
Oct 23, 2002
574
AU
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 :)
 
.ActiveDocument.Bookmarks("FirstName").Select
.Selection.Text = Me![FirstName]
.ActiveDocument.Bookmarks.Add Name = FirstName

.ActiveDocument.Bookmarks("cost").Select
.Selection.Text = Me![PositionID]
.ActiveDocument.Bookmarks.Add Name = cost

Works for First Name but costcentre data comming from different table has ID number and not data

Never give up never give in.

There are no short cuts to anything worth doing :)
 
Displays first name in word

.ActiveDocument.Bookmarks("FirstName").Select
.Selection.Text = Me![FirstName]
.ActiveDocument.Bookmarks.Add Name = FirstName


Does not display data only ID numrer as date stored in position table

.ActiveDocument.Bookmarks("cost").Select
.Selection.Text = Me![PositionID]
.ActiveDocument.Bookmarks.Add Name = cost

Never give up never give in.

There are no short cuts to anything worth doing :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top