I have the following macro. It should print a 5-digit number from the subject line from an open Outlook email. An example topic line would be "Thank you. Order: # 98512" (without quotes).
I have a library checked in Outlook links for Regex 5.5.
I do not get any output. Only the following error.
The bug highlighter throws and error:
Run-Time error '450':
Wrong Number of arguments or invalid property assignment
With highlights on the MsgBox orderNumber command.
Here is the current macro:
Sub ShowTitle()
Dim orderNumber
Dim orderRegExp
Dim regExVar As String
Dim CurrentMessage As MailItem
'Takes the email title from the subject line
Set CurrentMessage = ActiveInspector.CurrentItem
regExVar = CurrentMessage.Subject
'Regex out the order number from the regExVar
Set orderRegExp = New RegExp
orderRegExp.Pattern = " \d{5} "
orderRegExp.Pattern = True
Set orderNumber = orderRegExp.Execute(regExVar)
'displays in a message box
MsgBox orderNumber
End Sub
source
share