View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Automatically email a worksheet based on criteria being met

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.SendMail Recipients:="email.recipient@ address.here"
End Sub

go into the vbe and look in the project explorer. For your
project/workbook, select the ThisWorkbook entry and double click on it.

In the dropdowns as the top of the module.

From the left dropdown select Workbook
From the right dropdown select BeforeClose

You should get a declaration like this in the module.

Private Sub Workbook_BeforeClose(Cancel As Boolean)

End Sub


Now add you line of code to make it

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.SendMail Recipients:="email.recipient@ address.here"
End Sub

go back to Excel and save the workbook.

--
Regards,
Tom Ogilvy



"brisen09" wrote in message
...
Hi Tom

I have accessed the sites you suggested but I am still a bit confused.

I have placed the following code in the VB editor and it works if I
manually
run the macro. The problem is I have no idea where to put the other code
in
relation to this or what else needs to go with it.

The code i use to mail the file manually is:

Sub Email()
ActiveWorkbook.SendMail Recipients:="email.recipient@ address.here"
End Sub

The Workbook_BeforeSave command is the one that I would need to use to get
it sent automatically I think.

Would you mind completing the code string as I do not have programming
knowledge.

Thank you for your asistance with this, in anticipation.

Regards

Brian

"Tom Ogilvy" wrote:

Information on emailing:

http://www.rondebruin.nl/sendmail.htm


Information on events
http://www.cpearson.com/excel/events.htm

combination of the two should solve your problem.

--
Regards,
Tom Ogilvy


"brisen09" wrote in message
...
I am wondering if there is some way that a worksheet can be
automatically
emailed to a recipient upon it being updated.

I work away from my office network and need a file that is current and
having to get the staff to email me a copy is a drag. If there is some
way
that the file could be emailed automatically it would be great. By
automatically I also mean with limited user input if this is the only
option.

Any assistance would be greatly appreciated.

Regards

Brian