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

MS Word Mail Merge help.

Status
Not open for further replies.

CptCrusty1

Programmer
Feb 17, 2005
216
US
A colleague of mine has the unfortunate task of merging an Access table with MS Word templates. The problem with this is the vendor, which receives the word files, has mandated that each file have no more than 500 pages. Thus, the poor girl, once a week, has 53000 plus letters to merge in 250 record increments since each letter is 2 pages.

I've never manipulated MS Word from Access and don't know how hard it would be. Can anyone recommend some solutions to this? She's going to get so frustrated she'll have a melt down and I'll be stuck doing it instead of her.

Thanks
Crusty.

I live to work and I work to live.
 
You will find a great many posts on this topic, and several FAQs. This one, for example:
How to MAIL MERGE and SAVE EACH DOCUMENT SEPARATELY
faq68-5187
You will see from the above FAQ that it is quite posible to set a record count.

You may also wish to look at:
'Native' mailmerge reports - as painless as possible
faq181-5088
Which could be adapted to output n records.
 
Not quite sure of the specifics, so I will give some general thoughts and we'll see if one of the gurus will weigh in with the blow by blow.

Code:
Sub MergeToMSWord
'*****VARIABLE DECLARATIONS*****
Dim intRecCount As Integer, strSQL As String, intRecNum As Integer

'Initialize Variables, customize for your fields etc
     intRecNum = 1
     strSQL = "SELECT myTable.MyField1 etc. " _
     & "FROM myTable" _
     & "WHERE conditions....;"

'Run the query
     Docmd.RunSQL strSQL

'Read the record count from the select query that generates the letters into intRecCount variable

intRecCount = Whatever... not sure about lots of this

'Loop and Merge to Word
     For MergeRecs = intRecNum to intRecCount
         'instructions for outputting to Word here...
         'do stuff
          intRecNum = intRecNum + 1
     Next MergeRecs
End Sub

There's lots missing here. (ie the for next loop needs to look at blocks of 250, etc.)

This is just a general thought and maybe one of the top guns here can take this and do something sensible with it.

Tom


Live once die twice; live twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top