Hi mso3,
Thank you for posting the sample code. I was able to come up with a simpler solution, that will probably be easier for you to understand.
See the attached .zip file that contains the following files (all files have been modified since the previous update):
a. LJMOpenWordMailMerge7.xls - Excel file that runs Mail Merge
b. Birthday.docx - modified copy of your Word file.
c. SendMails.xls - modified copy of your Excel file.
To run Mail Merge the first time:
a. Extract the 3 files from the .zip file into the same folder.
b. Open file LJMOpenWordMailMerge7.xls
c. Left Click the Brown Shape at the Top Right to put the proper files and folders on lines 25 and 27.
d. Left Click the Yellow Shape at the Top Left to run the Mail Merge.
Please note that I added a few things to the Excel file that runs the Mail Merge:
a. User entry of a folder name where the Output Files will go.
b. User entry of a Mail Merge 'Field Name'. This is the Column in the Excel Data File that is used to create the 'Output File Name'.
c. User entry of 'First' and 'Last' Birthday to include. If 'Today' is wanted, the 'Birthday' cells can be left blank.
d. A command button that will display the 'Output File Folder' in using 'Windows Explorer'.
The following code excerpt is taken (out of context) from the attached file, and demonstrates how the Mail Merge Code works. Several statements not related directly to function have been removed for ease of readability.
Lewis
Bookmarks