![]() |
|
#1
|
|||
|
|||
|
Hello,
Im trying to perform a mail merge through VBA. A problem that I encouter is that my datasource has a CRLF (carriage return line feed) in the last row of the datasource. This causes a mailmerge error log to pop up and say "Record X Was an Empty Record". Ultimately im trying to get this separate sheet to either go away or only show up when there is a real error on a record. Im having difficulty finding a solution on skipping or even deleting the last row of the datasource. Ive tried messing with Code:
ActiveDocument.MailMerge.DataSource.RecordCount Here is what I have so far. Any help on how I can merge all but the last row or even delete the last row is appreciated. Code:
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:="FILEPATH", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, SubType:=wdMergeSubTypeOther
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
|
| Tags |
| mailmerge omit lastrecord |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to get datasource element | ragesz | Mail Merge | 1 | 09-29-2013 07:12 PM |
Mailmerge to Email with a mailmerge attachment
|
Baldeagle | Mail Merge | 8 | 02-11-2013 04:40 AM |
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 |