Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MACRO PROBLEM ??? JAYC099 Excel Worksheet Functions 2 August 14th 08 12:06 PM
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 Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
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 Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Problem with Macro rdwj Excel Discussion (Misc queries) 0 March 28th 07 01:13 AM
macro problem hombreazul Excel Discussion (Misc queries) 2 March 16th 06 10:54 PM


All times are GMT +1. The time now is 06:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"