View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default Doug's Attachment macro-handling empty cells

The following modification to the code will check to see if there is a colon
in the cell, as there would be if it contains the path and filename of an
attachment, and only add the attachment if there is:

For i = 2 To Maillist.Tables(1).Columns.Count
Set Datarange = Maillist.Tables(1).Cell(Counter, i).Range
Datarange.End = Datarange.End - 1
If InStr(Datarange, ":") 0 Then
.Attachments.Add Trim(Datarange.Text), olByValue, 1
End If
Next i


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"aeacsharp" wrote in message
oups.com...
I;m sorry, i mis-stated something he
"But in my case, I would like the macro to handle cases in which
**rows** in the "directory" word file are empty, moving on to the next
row/record "

for "rows" substitute the word "cells". I need help in handling empty
cells in the "directory" word file, so that the macro VB does not
"break" when an attachment path resolves to "".

my apologies!