Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-30-2017, 04:32 PM
vincenzo345 vincenzo345 is offline VBA mailmerge all but last row in datasource Windows 7 64bit VBA mailmerge all but last row in datasource Office 2016
Novice
VBA mailmerge all but last row in datasource
 
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
 

Tags
mailmerge omit lastrecord

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get datasource element ragesz Mail Merge 1 09-29-2013 07:12 PM
VBA mailmerge all but last row in datasource Mailmerge to Email with a mailmerge attachment Baldeagle Mail Merge 8 02-11-2013 04:40 AM
VBA mailmerge all but last row in datasource Mailmerge to Email with a mailmerge attachment Baldeagle Mail Merge 13 05-29-2012 02:04 PM
Access MailMerge DataSource in VB advin Mail Merge 1 01-04-2010 01:34 AM
Changing DataSource ntfirewall Mail Merge 0 03-30-2007 06:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft