View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
mcescher mcescher is offline
external usenet poster
 
Posts: 24
Default Auto notify a list of people via email when excel file is closed

Melanie,
You might want to try vbSendMail. It's a VB add-on. (Your macro is
actually a VBA program)

I would suggest a 'Settings' tab. You could have the different email
lists there. This would allow easy updates to the lists, rather than
re-writing the code when a different person has to be added to the
list. Use a function like this to retrieve the addresses.

Public Function GetEmails()
Dim intRow As Integer, strEmails As String
intRow = 5: strEmails = ""
Do While Not IsEmpty(Sheets("Settings").Range("A" & intRow))
strEmails = strEmails & Sheets("Settings").Range("A" & intRow) & ";
"
intRow = intRow + 1
Loop
GetEmails = Left(strEmails, Len(strEmails) - 2)
End Function

My list is in column A starting at row 5. This will read all the
addresses until there is an empty cell

You might want to set that up with a button to process your choice
rather than when you close. The button could save the workbook, send
the email and then close it. Use these two commands with your code in
the onclick of the button.
ActiveWorkbook.Save
ActiveWorkbook.Close

Look into the Select Case statement in the help menu. This will help
you determine which selection was made. Something like this:
Select Case strChoice
case "N/A"
'No notification
case "Grp1"
'send email to first group
case "Grp2"
'send email to second group
case "Grp3"
'send email to third group
End Select

HTH,
Chris M.