Stuart McLachlan
stuart at lexacorp.com.pg
Fri Apr 16 18:30:01 CDT 2010
I wouldn't use Mail Merge in this situation, I'd use the Word Object Model and a template
document with bookmarks.
It's what is used to create all of the job descriptions and application forms at
http://www.vanguardpng.com/current_vacancies.html
The core code is:
Set rs = CurrentDb.OpenRecordset("select * from qryApplication where PositionNUmber
= " & Position)
'Create doc with appropriate name from template with hidden bookmarks
strTemplate = "VI-FORM1.DOC"
strDir = BEDir() & "\JobApplns\"
strDoc = "VI-Appln-" & rs!Positioncode & ".doc"
FileCopy strDir & strTemplate, strDir & strDoc
'Open the Document
Set objDoc = objWord.Documents.Open(strDir & strDoc)
' Insert relevant text at bookmarks
objWord.Selection.GoTo What:=wdGoToBookmark, Name:="PositionNo"
objWord.Selection.TypeText Text:=rs!Positioncode
objWord.Selection.GoTo What:=wdGoToBookmark, Name:="Position"
objWord.Selection.TypeText Text:=rs!PositionTitle
objWord.Selection.GoTo What:=wdGoToBookmark, Name:="Client"
...
--
Stuart
On 16 Apr 2010 at 14:23, John Clark wrote:
> Well, at the risk of repeating myself...if anyone remember my attempt
> to do this, back in December...I have never created a form in Word and
> passed to it, data from an Access DB...and now I have a need to do
> such a thing. I "got around" this, back then, by actually creating the
> whole document as an Access report, as I was guided to do, by several
> list members here. This was fantastic advice, and it was great in that
> circumstance...however, it just isn't in the cards on this project. I
> immediately tried doing this, but the header, of all things, prevents
> me from going this way...the logo just looks awful, when done in
> Access...don't know why, it just does. I don't have the time to do
> anything w/this, and don't know if I could anyhow, so I'm going to go
> ahead and try doing this w/Word.
> My 1st question...is a mail merge what I am looking at doing? I'm only
> looking to create a single document at a time...a certificate...that I
> will be using a query to gather. The user will enter information on a
> student, and they will then print a certificate for that student. The
> query choose one single student, based on the record currently active
> in the form.
> I'm following instructions for a mail merge, but I get to a point
> where it wants my list of "recipients." I don't really have this, I
> simply have data, and I want to create one single document at a time,
> using this data.
> Am I barking up the wrong tree here? Should I be looking at something
> else, or is it indeed a mail merge, that I am trying to do?
> Thanks ahead of time...J Clark
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com