Send Attachment (previous one got away)

M

MLT

I'm using a code from the Walkenbach book to send a single sheet from
a workbook in an email:

Sub SendOneSheet()
Dim Filename As String
Filename = "my file.xls"
ActiveWorkbook.Worksheets("sheet1").Copy

To this point everything makes sense to me. Then...

ActiveWorkbook.SaveAs Filename <--- How does this step know to
save the copied "sheet1" and save that as Filename?

ActiveWorkbook.Sendmail "(e-mail address removed)", "My Sheet" <---
Here, what tells it to attach the saved file to the email?

ActiveWorkbook.Close False
Kill Filename
End Sub

Got the rest. Another twist I'd like to use would be to copy the
"sheet1" and PasteSpecial Values so that all formulas are eliminated,
leaving just the result of the formula at the time of the code being
run...

Thanks for any help.
 
D

Dave Peterson

Try copying a sheet from an existing workbook manually. You'll see that the
activesheet becomes the newly copied sheet. Same with the activeworkbook.

After the .copy line

with activesheet.cells
.value = .value
end with

or
with activesheet.cells
.copy
.pastespecial paste:=xlpastevalues
end with
 
M

MLT

I'm using a script written by Ron Debruin to send an email with an
attachment. I'm not sure its necessary to repost that code here but
I'm trying to figure out what part of the code actually sends the
email. What I'd like to do is cut the code just short of sending the
message so that the user can add text to the body of the message, then
send it when ready. Help?
 
R

Ron de Bruin

Hi MLT

If you use the Outlook object model code from my site you
can change .Send to .Display

If you use the code from the first section of my mail page
the only way is to leave the To string empty

Choose a address in the address book of your mail program.
When you use "" you can choose a mail address in your address book.

.SendMail "", "This is the Subject line"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




MLT said:
I'm using a script written by Ron Debruin to send an email with an
attachment. I'm not sure its necessary to repost that code here but
I'm trying to figure out what part of the code actually sends the
email. What I'd like to do is cut the code just short of sending the
message so that the user can add text to the body of the message, then
send it when ready. Help?



__________ Information from ESET Smart Security, version of virus signature database 3943 (20090317) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 3943 (20090317) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
R

Ron de Bruin

You are welcome

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




MLT said:
Duh, it was right there in the commenting. That works perfectly,
thanks!

__________ Information from ESET Smart Security, version of virus signature database 3943 (20090317) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 3943 (20090317) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

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