i currently have a form with a textbox and a button. you can enter any number in the textbox and when you hit the button it will show the number on a message box, but if there is an error, a message will pop up and you can click the debug button to see which line gave an error. This will be for the code:
On Error GoTo 0:
But if i replace the 0 with "error:", it will take me to a new subroutine that will send me an email regarding the issue but it will not highlight the line which gave me an error when i hit the debug button.
Is there a way i can send myself an email AND when i hit the debug button it will highlight the error line?
Private Sub CommandButton1_Click()
'on error goto error:
On Error GoTo 0:
Dim word As Double
word = TextBox1.Text
MsgBox word
Exit Sub
error:
Call error()
End Sub
Sub error()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "error"
With OutMail
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = "error"
.Body = strbody
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Debug.Assert (Err.Number & Err.Description)
End Sub