Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an email w/attachment from Excel 1

Status
Not open for further replies.

jessedh

MIS
Apr 16, 2002
96
US
I am looking for a piece of code that will generate a new email with a specific file attached and allow me to edit the recieptents.

I have tried the SendMailfunction and since the workbook that I want to send isn't the active one, first I have to open it and then send the email and then close it. I was wondering if there was an easier way...

Thanks
jesse
 
Jesse,

This should work...

Simply place it into a separate file, and of course specify the exact path\filename you wish to email.

Sub Open_and_Email_File()
Workbooks.Open "c:\path\filename.xls"
Application.Dialogs(xlDialogSendMail).Show
End Sub

Hope this is what you wanted. :) Please advise.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca

 
this worked, but since it is a read-only wb, I get an error message, any clue how I can disable this?

Its says:
'"DAILYRATES.xls" should be opened as a read-only unless you need to save changes to it. Open as read-only?' (YES/NO)

How can I just default to Yes?

Thanks
Jesse
 
In Explorer, right-click on the file, and un-check Read-only. :)

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Sorry... I should have said... Right-click, THEN choose "Properties" - and then un-check Read-only.

 
It isn't read-only, its b/c it has protected sheets that need to be protected...
 
Jesse,

I'm not certain I understand "completely", BUT, if you want to open a "Read-Only" file and "bypass" the YES/NO question, use the following "modified" routine...

Sub Open_and_Email_File()
Workbooks.Open "c:\path\filename.xls"
Application.Dialogs(xlDialogSendMail).Show: ReadOnly = True
End Sub

Hope this is now what you wanted. :)

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
It's been a LONG day... I pasted the ":ReadOnly = True" to the WRONG line. It should of course be...

Sub Open_and_Email_File()
Workbooks.Open "c:\path\filename.xls": ReadOnly = True
Application.Dialogs(xlDialogSendMail).Show
End Sub

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca

 
That still gave the error message, what worked was that the code that produced the file had prompt = true, so I just disabled that and it worked with ur code....thanks again..

Jesse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top