Link to home
Start Free TrialLog in
Avatar of Hanlo Reyneke
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
Avatar of Madmarlin
Madmarlin

Listening...
ASKER CERTIFIED SOLUTION
Avatar of daffyduck14mil
daffyduck14mil

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
* 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.
Avatar of Hanlo Reyneke

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:\WINDOWS\Desktop\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