Shazam
03-14-2007, 01:38 PM
Hi everyone,
I have this code below it will attach multiple files that are listed in column A from a excel worksheet. What I'm trying to do is to expand the range from column A to column D. So I tried to adjust the code from this:
Range("A2:A9").Value
into this
Range("A2:D9").Value
but it did not work it will only look in column A. Any help?
Here is a link where I got the code from.
http://www.vbaexpress.com/forum/showthread.php?t=11058
Sub Email()
Dim objol As New Outlook.Application, objMail As MailItem
Dim MyArr As Variant, i As Long
Set objol = New Outlook.Application
Set objMail = objol.CreateItem(olMailItem)
With objMail
MyArr = Sheets("Sheet1").Range("A2:D9").Value
.To = ("Nobody@home.com") ' Name of distribution list in Contacts
.Subject = Range("A1")
.Body = ""
.NoAging = True
For i = LBound(MyArr) To UBound(MyArr)
If Dir(MyArr(i, 4) & ".xls", vbNormal) <> "" Then .Attachments.Add MyArr(i, 1) & ".xls"
Next i
.Display
End With
End Sub
I have this code below it will attach multiple files that are listed in column A from a excel worksheet. What I'm trying to do is to expand the range from column A to column D. So I tried to adjust the code from this:
Range("A2:A9").Value
into this
Range("A2:D9").Value
but it did not work it will only look in column A. Any help?
Here is a link where I got the code from.
http://www.vbaexpress.com/forum/showthread.php?t=11058
Sub Email()
Dim objol As New Outlook.Application, objMail As MailItem
Dim MyArr As Variant, i As Long
Set objol = New Outlook.Application
Set objMail = objol.CreateItem(olMailItem)
With objMail
MyArr = Sheets("Sheet1").Range("A2:D9").Value
.To = ("Nobody@home.com") ' Name of distribution list in Contacts
.Subject = Range("A1")
.Body = ""
.NoAging = True
For i = LBound(MyArr) To UBound(MyArr)
If Dir(MyArr(i, 4) & ".xls", vbNormal) <> "" Then .Attachments.Add MyArr(i, 1) & ".xls"
Next i
.Display
End With
End Sub