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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel 2000 vba 1

Status
Not open for further replies.
Joined
Nov 27, 2001
Messages
162
Location
GB
can any one help with an excel 2000 query. do you know the code for a macro to send a selected worksheet rather than the workbook via email?

thanks for your help
________________________________________

The Collective known as
The UK Alliance
________________________________________
 
I don't think you can do it directly but simply:

Copy the sheet to a new workbook

then use Sendmail method

On Error GoTo ErrorHandler
ActiveWorkbook.sendmail Recipients:=sendto, Subject:=EmailTitle, RETURNRECEIPT:=True
On Error GoTo 0

ErrorHandler
MsgBox Prompt = "Sendmail failure for " + sendto + ". Probably invalid email address or mailbox if full"
End sub
 
UkAlliance,

I believe this is the code you're looking for...

Sub EMail_CurrentSheet()
Dim File_Name As String
File_Name = ThisWorkbook.Name
ActiveSheet.Copy
ActiveWorkbook.SendMail _
Recipients:="dwatson@bsi.gov.mb.ca", _
Subject:=File_Name
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
End Sub

I hope this helps. :-)

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Thanks Dale. that has worked perfectly.

Just one more question....how would I add in a text box where you could type in the recipient email address rather than specify it in the coding itself? ________________________________________

The Collective known as
The UK Alliance
________________________________________
 
I know you can just remove the email address from the coding and leave the 2 " marks and then this will give the email and ask you to type in the TO field. ________________________________________

The Collective known as
The UK Alliance
________________________________________
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top