My Macro problem

A

Al Jager

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top