By using vba.booksticle.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

948 Steps to 6 Figures by Learning Excel-VBA and Other Skills



Step 712 - EmailMsgBox


This is an example of extending VBA by creating a new function.

Problem:

You want to pop up a MsgBox to the user but also send an email to yourself that something went wrong.

Another way to do this would be to log the error to a file and then have an Excel/VBA process to monitor the file.



Function EmailMsgBox(sText As String) As Variant
'This routine will email the support person and display a message box
Dim sOrigText As String

sOrigText = sText

WarnDev sText



MsgBox sOrigText

If Dir("C:\stop.txt") <> "" Then
    Stop
End If



End Function



   Table of Contents | Send us your feedback | © 2025 All Rights Reserved | Edit