E-mail Files From Files

  • Thread starter Thread starter SmartyPants
  • Start date Start date
S

SmartyPants

Is there any VBA coding that will allow me to e-mail a file from within
that file?

I want to be able to put a button in an excel file that will let me
e-mail the file it is in to a list of pre-assigned e-mail addresses.

We are a Lotus based e-mail system here, I don't know if that affects
anything.

Any help would be appreciated.
 
Private Sub CommandButton1_Click()
'This will temporarily save the Spreadsheet and then
'e-mail the saved file to someone else
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim wbname As String

' Stop screen updating
Application.ScreenUpdating = False
Set wb1 = ActiveWorkbook
'Create the temporary file name
wbname = "C:/" & wb1.Name & "" & Format(Now, "dd-mm-yyyy h-mm-ss") &
".xls"
'Save the temporary file
wb1.SaveCopyAs wbname
'Open the temporary file
Set wb2 = Workbooks.Open(wbname)
'using the temporary file create an email
With wb2
.SendMail "(e-mail address removed)", "Subject"
.ChangeFileAccess xlReadOnly
' delete the temporary file
Kill .FullName
.Close False
End With
' start screen updating
Application.ScreenUpdating = True
End Sub
 

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

Back
Top