Dear experts:
Hope you are having a great week!
I'm having a hard time validating the information provided on an inputbox, it must be an email from the outlook domain. This is the code I'm using to evaluate the email provided (ROemail)
ROemail = Application.InputBox("Please enter your email to receive notifications about the status of this format.", Title:="Risk owner Email address", Default:="email@outlook.com", Type:=2)
If StrPtr(ROemail) = 0 Then
MsgBox ("Action cancelled by user. QA not requested!")
Exit Sub
ElseIf ROemail = vbNullString Then
MsgBox ("No email entered. Please provide a valid email")
Else
If ValidateEmailAddress(ROemail) = False Then
MsgBox ("The information provided is not a valid email from the Outlook domain, please verify.")
Else
'DO STUFF
End If
End If
The Function ValidateEmailAddress() that validates the String goes like this:
Public Function ValidateEmailAddress(ByVal ROemail As String) As Boolean
On Error GoTo Catch
Dim objRegExp As Object
Dim blnIsValidEmail As Boolean
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "^(([\w\d\-\_\.])+@outlook\.com,*\s*)+$"
blnIsValidEmail = objRegExp.Test(ROemail)
ValidateEmailAddress = blnIsValidEmail
Exit Function
Catch:
ValidateEmailAddress = False
End Function
But for some reason it's not working and it's sending me this errors related to the objRegExp, It's the first time using a function and a Regular Expression so I'm not sure if I'm doing something wrong or something is missing.
Could you please advice me?
Thank you so much in advance!
Bookmarks