![]() |
My Macro problem
Sorry, The previous posting "escaped" before I could
complete my request. In the macro I refer to the file that has to be attached. Instead of pointing to the file using the path etc. I want to attach the active workbook. Could someone tell me how to to that please? Many thanks. Al Sub SendMail() Dim objOutlook As Object Dim objMailItem As Object Dim objRecipient As Object Set objOutlook = CreateObject("Outlook.Application") Set objMailItem = objOutlook.CreateItem(0) Set objRecipient = objMailItem.Recipients.Add (ActiveSheet.Range("B2").Value) objRecipient.Type = 1 '1 = To, use 2 for cc objMailItem.Subject = "The extract has finished." 'Instead of the path to the file - ' I want to insert Active Workbook in the next line objMailItem.Attachments.Add ("C:\Al Jager\! Book Test1.xls") objMailItem.Display End Sub |
My Macro problem
Al,
You can't use activeworkbook, as an attachment has to be from disk. So if you want to attach the activeworkbook, you need to first save it, and then use Activeworkbook.Fullname. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Al Jager" wrote in message ... Sorry, The previous posting "escaped" before I could complete my request. In the macro I refer to the file that has to be attached. Instead of pointing to the file using the path etc. I want to attach the active workbook. Could someone tell me how to to that please? Many thanks. Al Sub SendMail() Dim objOutlook As Object Dim objMailItem As Object Dim objRecipient As Object Set objOutlook = CreateObject("Outlook.Application") Set objMailItem = objOutlook.CreateItem(0) Set objRecipient = objMailItem.Recipients.Add (ActiveSheet.Range("B2").Value) objRecipient.Type = 1 '1 = To, use 2 for cc objMailItem.Subject = "The extract has finished." 'Instead of the path to the file - ' I want to insert Active Workbook in the next line objMailItem.Attachments.Add ("C:\Al Jager\! Book Test1.xls") objMailItem.Display End Sub |
All times are GMT +1. The time now is 02:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com