ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   attachment - then email from excel! (https://www.excelbanter.com/excel-discussion-misc-queries/71687-attachment-then-email-excel.html)

dj_siek

attachment - then email from excel!
 

Hi All!

I have a macro runing outlook. it all works, but I want the file that
is created as a variable - the one sheet of it as below , to be emailed
as the attachment. So its first saved (user in puts the version number),
then that file that is saved is emailed.

CODE:

Private Sub CommandButton1_Click()

variable = InputBox("Please enter a version number", "Version")

Sheets("SCHD").Select
Sheets("SCHD").Copy
ChDir "C:\Documents and Settings\eggenhuizenj\Desktop"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\username\Desktop\Target Refit 2006
Schedule Ver " + variable + ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

attach = Windows("Target Refit 2006 Schedule Ver " + variable +
".xls").Activate
ActiveWindow.Close

'Create a new Workbook Containing 1 Sheet _
and sends as attachment.
With ActiveWorkbook
attachment - created above
.SendMail ", _
Subject:="Find attached blah " & Format(Date, "dd/mmm/yy")
.Close SaveChanges:=False
End With
End Sub

END CODE


Any help would be greatly appreciated,


thanks!

Joel


--
dj_siek
------------------------------------------------------------------------
dj_siek's Profile: http://www.excelforum.com/member.php...o&userid=31247
View this thread: http://www.excelforum.com/showthread...hreadid=512492



All times are GMT +1. The time now is 09:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com