1 Replies - 2175 Views - Last Post: 24 May 2010 - 10:44 AM

#1 P4L   User is offline

  • Your worst nightmare
  • member icon

Reputation: 34
  • View blog
  • Posts: 2,789
  • Joined: 07-February 08

mail merge

Posted 20 May 2010 - 10:55 AM

Description: Connect the Word doc back into the database using a DDE connection (used MS Access as database). Create form with either action button, radio button, or some sort of way to call the function. Put an event procedure on said device, having it call the function.Here is a function to call Word for a mail merge using VB with autoprint of newly created merge doc.
Function MergeIt()

Dim objWord As Word.Document
Set objWord = GetObject('"EnterFilePathandName.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source.
    With objWord.MailMerge
        .MainDocumentType = wdFormLetters
        .OpenDataSource Name:='"EnterFilePathandName.xls", LinkToSource:=True, Connection:="TABLE tblClients"
        
    End With
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.MailMerge.Destination = wdSendToPrinter 'wdSendToNewDocument; wdSendToFax; wdSendToEmail
'Closes Word when done
objWord.Application.Quit (False)

End Function


Is This A Good Question/Topic? 0
  • +

Replies To: mail merge

#2 NeoTifa   User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4545
  • View blog
  • Posts: 19,181
  • Joined: 24-September 08

Re: mail merge

Posted 24 May 2010 - 10:44 AM

neat
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1