View Single Post
 
Old 08-30-2017, 04:32 PM
vincenzo345 vincenzo345 is offline Windows 7 64bit Office 2016
Novice
 
Join Date: Aug 2017
Posts: 13
vincenzo345 is on a distinguished road
Default

Thanks for that Idea, I think it'll work but im kind of clueless in regards to how that sql qry works.

Code:
 
 
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:="C:\DATA\" & Environ("USERNAME") & "\Word.txt", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, sqlstatement:="SELECT * FROM activedocument.MailMerge.DataSource WHERE ActiveDocument.MailMerge.DataSource.DataFields(2).Value IS NOT NULL", SubType:=wdMergeSubTypeOther
 
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
The datasource file is word.txt. I wasnt able to find how to reference the table and field for the sql qry.In regards to the Qry I had written, I was expecting it to qry word.txt and process all rows where field 2 is not null. Any idea on what im doing wrong?
Reply With Quote