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

Access & Word 97 VBA/MailMerge multiple printouts

Status
Not open for further replies.

slickpg

Programmer
Sep 8, 2003
7
US
How do you print multiples word documents created from Access 97 database, using VBA code to invoke "Mail Merge"
without opening an occurrence of Word for every document that you want to print?

I can print 1 document with no problem. What this boils down to is that the users want to enter data for 10 records(for example) of the same letter and then print them all at one time?

Any tips would be appreciated !!!!!!!!
 
Hi

If I were doing it, I'd use Excel. Here's how.

1. Use Data/Get external data to get the required fields out of Access

2. Set up my "Form" in a separate sheet that has my "merge fields" (cells) and other text designed. Name each merge cell, the same name as the Access Field. Note: that if any Access field name contains spaces, substitute an UNDERSCORE for each space.

3. Once the data is imported, use AutoFilter to select the rows that you want to use

4. Paste this code into a module to loop thru the list and print each form...
Code:
Sub MergePrint()
  Dim wsForm As Worksheet, wsData As Worksheet, sRngName As String
  Set wsForm = Worksheets("My Form") 'change to your sheet name
  Set wsData = Worksheets("My Data") 'change to your sheet name
  With wsData.Cells(1, 1).CurrentRegion
    For r = 2 To .Rows.Count
      For c = 1 To .Columns.Count
        sRngName = wsData.Cells(1, c).Value
        Range(RangeName(sRngName)).Value = wsData.Cells(r, c)
      Next
      ActiveSheet.PrintOut
    Next
  End With
End Sub
Function RangeName(sName As String) As String
    RangeName = Application.Substitute(sName, " ", "_")
End Function
VOLA! :)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top