Discussion Locked

Automating Word from Outlook

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

This is my first attempt at an Outlook Macro.

Sub OutlookWordMerge()
Dim oOutlook As Outlook.Application
Dim oWord As Word.Application
Set oOutlook = CreateObject(?Outlook.Application?)
Set oWord = CreateObject(?Word.Application?)
Dim oContact As ContactItem
Dim oContacts As Outlook.Selection
Dim oDoc As Word.Document
Set oContacts = oOutlook.ActiveExplorer.Selection
For Each oContact In oContacts
Set oDoc =
oWord.Documents.Add(?C:\WinNT\Profiles\Dave\Application
Data\Microsoft\Templates\Letter1.dot?)
oDoc.Bookmarks(?Name?).Range.Text = oContact.FullName
Next
End Sub

I have a template called letter1.dot with a bookmark called Name.
This does not produce any errors but does not produce any documents
whether
I have Word opened or closed.
What have I missed

5 replies

by suemvp

The question from jeff@truegeeks.com was quite relevant. Your code does not include any command to either save the document or make it visible. You need to do one or the other. At the very least you can try:

oWord.Visible = True
oDoc.Activate

This discussion is closed to new replies.