Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
MACRO PROBLEM ??? | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Discussion (Misc queries) | |||
Problem with Macro | Excel Discussion (Misc queries) | |||
macro problem | Excel Discussion (Misc queries) |