email as attachment in code

H

hommer

Hi, all!
I have a program that inserts data into excel worksheet.
Now I want to email it. I need your help to find the code equivalent of
manually select menu File/SendTo/Mail Recipient(As Attachment), then type in
a recipient address and send.
I have this line of code:
Call xlsWorkbook.SendMail("(e-mail address removed)", "ACD", "")
I got runtime error 1004. Method 'SendMail' of object '_workbook' failed.
I am not sure I am using the right object. I have app, workbook and
worksheet, and I used workbook to save it.
Thanks!
 
T

Tom Ogilvy

sendmail is a method of the workbook, so it appears you are using the correct
object if xlworkbook is a reference to the workbook you want to send


try changing the last argument to False

Call xlsWorkbook.SendMail("(e-mail address removed)", "ACD", False)

or omitting it

Call xlsWorkbook.SendMail("(e-mail address removed)", "ACD")
 
H

hommer

Great! Tom, it works! Thanks!

Tom Ogilvy said:
sendmail is a method of the workbook, so it appears you are using the correct
object if xlworkbook is a reference to the workbook you want to send


try changing the last argument to False

Call xlsWorkbook.SendMail("(e-mail address removed)", "ACD", False)

or omitting it

Call xlsWorkbook.SendMail("(e-mail address removed)", "ACD")
 

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