Kamis, 03 Mei 2012

[ExcelVBA] macro help

 

Hi
i am using below macro code, mail will sent but attachement not add, i cound't where i made mistake so anybody help me

i have generated report from saved path
C:\Documents and Settings\z004497\Desktop\Desktop Files2\macro working\OutputData\

saved file path
C:\Documents and Settings\z004497\Desktop\Desktop Files2\macro working\OutputData\october.xls

B11 - ExportPath
B18 - FName

macro code:
Sub Mail_Workbook()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim OutApp As Object
Dim OutMail As Object
Dim ExportPath As String
Dim FName As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
ExportPath = Range("B11").Value
FName = Range("B18").Value
With OutMail
.To = "xxxxx"
.CC = ""
.Subject = "xxxxx"
.Body = "xxxxxxxxxx"
.Attachments.Add FileName:=ExportPath & FName & ".xls"
.Send

End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

mail will sent but attached not add, can u anybody help me

Thanks
Jegatheesan

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar