Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I am writing an application that will accept pipe "|" delimited text files
from other applications to be mail merged when receive. I can pick the files up from the directory, open the main mail document and open the data source; however when the opendatasource command is executed a dialog box pops up asking "Text File Connection Properties". I need to pass all the information for the mail merge programmatically. This program should run in the background with no user interaction. I am using Visual Studio - Visual Basic - Word 2003. The code I am using is below. Any help would be appreciated. 'Logic for processing found files here. Private Sub ProcessFile(ByVal filename As String, ByVal formfilename As String, ByVal datafilename As String) Dim wrdApp As Word.Application Dim wrdDoc As Word._Document Dim wrdSelection As Word.Selection Dim wrdMailMerge As Word.MailMerge Dim wrdMergeFields As Word.MailMergeField Dim ApplicationDisplayAlerts As Word.WdAlertLevel ' Create an instance of Word and make it invisible. wrdApp = CreateObject("Word.Application") wrdApp.Visible = False ApplicationDisplayAlerts = Word.WdAlertLevel.wdAlertsNone ' Open document. wrdDoc = wrdApp.Documents.Open(formfilename) wrdDoc.MailMerge.OpenDataSource(Name:=filename) wrdMailMerge = wrdDoc.MailMerge() ' Perform mail merge. wrdMailMerge.Destination = _ Word.WdMailMergeDestination.wdSendToPrinter wrdMailMerge.Execute(False) ' Close the original form document wrdDoc.Saved = True wrdDoc.Close(False) ' Release References. wrdSelection = Nothing wrdMailMerge = Nothing wrdMergeFields = Nothing wrdDoc = Nothing wrdApp = Nothing End Sub 'ProcessFile |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
printing difficultiies using mail merge in word | Mailmerge | |||
Editing Mail Merge Recipients | Mailmerge | |||
ASP.NET - Excel - Mail Merge in Word causes "Data Link Properties" dialog to appear. | Mailmerge | |||
mail merge with attachments | Mailmerge | |||
How to remove unwanted formatting in mail merge for cells witn no | Mailmerge |