View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ruic ruic is offline
external usenet poster
 
Posts: 30
Default E-mail Files From Files

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 ", "Subject"
.ChangeFileAccess xlReadOnly
' delete the temporary file
Kill .FullName
.Close False
End With
' start screen updating
Application.ScreenUpdating = True
End Sub


--
Rui Caetano
IT Manager
Township of East Hanover, NJ

"SmartyPants" wrote in message
oups.com...
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.