Although I've just started messing with Word automation, I've been able to create word documents from Access forms using the following code:
I used the following to pass just the form's current record to word using an On Click event.
Dim objWord As Word.Application
'Start Microsoft Word
Set objWord = createObject("Word.Application"
With objWord
'Make Word visible
.Visible = True
'Open the document
.Documents.Open ("C:\MyMerge.dot"
'Move to the bookmark and insert text from the form
.ActiveDocument.Bookmarks("First".Select
.Selection.Text = (CStr(Forms!Employees!FirstName))
You need to make a template in Word, and then place Bookmarks into the Word doc (Insert, Bookmark). Give the bookmark a meaningful name (Like FirstName) and then you save it.
In Access, reference the word bookmark in code like:
.ActiveDocument.Bookmarks("FirstName".Select
Then put the date from your form into the word bookmark by using this code:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.