Hanlo Reyneke
asked on
Merging og a word doc
I have a word doc which is my main doc and then I have a csv file which is my datasorce. I want to know what object already build into VB, I can use to merge the two documents. The result must be files which will be mail away. I have Office 2000 wich also contains objects that I can use. Can someone please give me sample code on how to do this. Thank you
Listening...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
* scratches his head and points out a few more things *
- You need to reference the Microsoft Word objects in your project references, otherwise you need to use late binding in your program, which slows down things.
Grtz.©
D.
- You need to reference the Microsoft Word objects in your project references, otherwise you need to use late binding in your program, which slows down things.
Grtz.©
D.
ASKER
Thanx, I took you code and mod it a bit and got what I was looking for. This is what I used.
Private Sub PrintLetter()
Dim oDocument As Word.Document
Set oDocument = New Word.Document
Set oDocument = Word.Documents.Add_("C:\WI NDOWS\Desk top\Letter .doc")
With oDocument.MailMerge
.Destination = wdSendToEmail
.MailAsAttachment = True
.MailSubject = "Test Letters"
.SuppressBlankLines = True
.Execute
End With
oDocument.Close wdDoNotSaveChanges
Set oDocument = Nothing
End Sub
Private Sub PrintLetter()
Dim oDocument As Word.Document
Set oDocument = New Word.Document
Set oDocument = Word.Documents.Add_("C:\WI
With oDocument.MailMerge
.Destination = wdSendToEmail
.MailAsAttachment = True
.MailSubject = "Test Letters"
.SuppressBlankLines = True
.Execute
End With
oDocument.Close wdDoNotSaveChanges
Set oDocument = Nothing
End Sub