Email on save
Paul Doucette wrote:
Is there a way I can set up my spreadsheet to send an email to alert others
in my company that it has been updated, every time I save it?
I have to ask, do you *really* want to generate an email alert *every time
you save*? This strikes me as a really bad idea. I tend to save my
spreadsheets every time I change *anything*; I doubt folks would like to
receive 600 emails a day from me saying "lol changed the spreadsheet again".
Instead, I would do something like this (in the spreadsheet's ThisWorkbook
class):
Private saved As Boolean
Private Sub Workbook_Open()
saved = False
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
saved = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If saved Then generateEmail
End Sub
Public Sub generateEmail()
'send the email; you figure out how
'then...
saved = False
End Sub
This way, you can send the email reports via code whenever you want, but if
you forget to, it happens automagically when you close the spreadsheet.
--
Their education has been sadly neglected.
|