I’m trying to use a macro that automatically e-mails the file. Problem is the file won’t always have the same name, but I found this code on the internet that claims it uses the filename of the current ActiveWorkbook. I however get an error every time I try it this way. Code looks like this:
Dim myOutlook As Object
Dim myMailItem As Object
Set otlApp = CreateObject(“Outlook.Application”)
Set otlNewMail = otlApp.CreateItem(olMailItem)
fName = ActiveWorkbook.Path & “” & ActiveWorkbook.Name
With otlNewMail
.To = "Brian_Budd@cable.comcast.com; klopeks@comcast.net "
.Subject = “Pending Disco Report”
.Body = “Attached is today’s Report.” & Chr(13) & “Regards,” & Chr(13) & “Ben” & Chr(13) & Chr(13)
.Attachments.Add fName
.Send
End With
otlApp.Quit
Set otlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
the problem is, both of these lines are giving me an error:
fName = ActiveWorkbook.Path & “” & ActiveWorkbook.Name
and
.Attachments.Add fName
any one have any idea what the problem is here? How do I tell it to attach the active workbook if I don’t know what the name is always going to be?