Automate Mail Merge of contact?

J

John Mulvaney

A techie in my company solved my problem for me, so I
thought I would post it here in response to my own query.

The answer that worked for me was to create my basic Fax
Cover template with "field" place holders. Then create a
macro at the "outlook" level (as opposed to "project"
level), then add a toolbar button to the open contact
form to run the macro. The macro opens the template doc,
finds the field placeholders and substitutes values from
Outlook. Source follows:

Sub CreateFaxCover()
Set myinspector = Me.ActiveInspector
Set MyContact = myinspector.CurrentItem
OpenWord MyContact
End Sub
Sub OpenWord(MyContact)
Set appWord = CreateObject("Word.Application")
If Not appWord.Visible Then
appWord.Visible = True
End If

Set oDoc = appWord.Documents.Add("C:\CreateFaxCover.doc")

For Each fldField In oDoc.Fields
If fldField.Result.Text = "«Full_Name»" Then
fldField.Result.Text = MyContact.FullName
End If

If fldField.Result.Text = "«Company»" Then
fldField.Result.Text = MyContact.CompanyName
End If

If fldField.Result.Text = "«Business_Phone»" Then
fldField.Result.Text =
MyContact.BusinessTelephoneNumber
End If

If fldField.Result.Text = "«Business_Fax»" Then
fldField.Result.Text = MyContact.BusinessFaxNumber
End If
Next
End Sub
 
Top