Attaching Excel through VBA

SimonJ

New Member
Joined
Jan 17, 2011
Messages
5
Hi,

I am trying to add a spreadsheet to an email and came across a code on another thread on here that works really well.

The only problem is that it sends the original saved version of my spreadsheet.

My user will be opening my spreadsheet from an intranet page and the vba will need to save a temporary copy for the user. Is there a way to change the code below so it saves a temporary copy and attaches that to an email instead of the original

Sub Button9_Click()

Dim OlApp As Object
Dim OlMail As Object
Dim ToRecipient As Variant

Set OlApp = CreateObject("Outlook.Application")
Set OlMail = OlApp.createitem(olMailItem)

For Each ToRecipient In Array("email.email.com", "Email2.email.com")
OlMail.Recipients.Add ToRecipient
Next ToRecipient

OlMail.subject = "Form" 'Subject field
OlMail.Attachments.Add ActiveWorkbook.FullName

OlMail.Display 'Display Email

End Sub



Thank You. Any help would be great
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,215,062
Messages
6,122,925
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top