ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Send Attachment (previous one got away) (https://www.excelbanter.com/excel-programming/424305-send-attachment-previous-one-got-away.html)

MLT[_3_]

Send Attachment (previous one got away)
 

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 ", "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.

Dave Peterson

Send Attachment (previous one got away)
 
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




MLT wrote:

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 ", "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.


--

Dave Peterson

Ron de Bruin

Send Attachment (previous one got away)
 
See also
http://www.rondebruin.nl/mail/folder1/mail2.htm

--

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


"MLT" wrote in message ...

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 ", "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.


MLT[_3_]

Send Attachment (previous one got away)
 
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?



Ron de Bruin

Send Attachment (previous one got away)
 
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" wrote in message ...
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




MLT[_3_]

Send Attachment (previous one got away)
 
Duh, it was right there in the commenting. That works perfectly,
thanks!

Ron de Bruin

Send Attachment (previous one got away)
 
You are welcome

--

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




"MLT" wrote in message ...
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





All times are GMT +1. The time now is 04:45 PM.

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