Mail Merge Using Visual Basic
Word Mail Merge Using VBA Access Mail Merge Only
Mail merge to a database or spreadsheet is a very common in the RFPs we receive.
For one or two page letters we recommend using Microsoft Access Visual Basic totally -
bypassing the activation of Microsoft Word and performing the merge operation directly in Access.
The end result of using Access directly to mail merge is that
you can provide a much simpler user interface and don't have the complications
of linking to the Access database from Word and don't have problems having to
filter the records or trying to figure out table names, query names and field
names to place into the mail merge Word document.
Steps are fairly simple:
1) Create a Microsoft Word document (two pages max) and format
it exactly as you want the resulting letter or document to appear.
2) In Word pick the Edit menu and then choose 'Select All',
then Edit again and select Copy. This will place of copy of the document
into your clipboard
3) Open up Microsoft Access and create a new blank report.
4) With the Edit menu choose Paste. This will place a
copy of the Word document into the Access report. The document will
retain the formatting and other characteristics since it is still a Word
Document. In the Access report the document will be an OLE field and
will likely be called OLE1
5) You can then assign the record source for the report using
either a table or query.
6) After the record source is defined you then can select the
database fields and simply drop them on top of the text in the Word Document.
Setting the Background field property to Normal will completely hide the Word
document text underneath the database field.
7) After aligning and sizing the database fields appropriately
you are ready to run the report.
Usually you want to filter to select some subset of your
database table. We use a little parameter form and filter a query or the
report itself.
Use the Site Search menu choice at the top of the page
to locate examples of
Using Form Fields to Filter Reports.
To see an advanced technique try search for
Using Global Variable as Parameters.
For simple letters and other communications you may find that using Word Bookmarks combined with Access Visual
Basic a better method to perform document mail merge.