I have been working on a VBA project that was created by another user, which has involved correcting many minor errors (mainly undeclared variables, etc.). I have worked everything out for the most part, except for the following section.
I get the 'Object or Library no found' error, as you do with undeclared variables, but I'm not sure what to do with this one...
I get the error on the function header, which looks to be the problem, but I'm not sure how to resolve this type of thing.
Any help would be appreciated.
I get the 'Object or Library no found' error, as you do with undeclared variables, but I'm not sure what to do with this one...
Code:
Public Function RetrievePMCollection(ByRef strToMatch As String, ByRef strPattern As String, _
Optional ByVal enmOptions As udeRetrievePMCollection_OPTIONS = 0) As MatchCollection
'Returns the match collection for the Pattern
If Len(strPattern) <> 0 Then ' tests that both required parameters are valid
Set objRegExp = New RegExp
objRegExp.Pattern = strPattern
objRegExp.Global = True
'Set options
If enmOptions <> 0 Then
objRegExp.IgnoreCase = ((enmOptions And enuRetrievePM_IgnoreCase) = enuRetrievePM_IgnoreCase)
objRegExp.Multiline = ((enmOptions And enuRetrievePM_MultiLine) = enuRetrievePM_MultiLine)
If (enmOptions And enuRetrievePM_RemoveVbCrLf) = enuRetrievePM_RemoveVbCrLf Then
strToMatch = Replace(strToMatch, vbCrLf, "")
strPattern = Replace(Replace(strPattern, "\r", ""), "\n", "")
End If
End If
On Error Resume Next ' // Added to handle malformed pattern strings
Set RetrievePMCollection = objRegExp.Execute(strToMatch)
If err.Number <> 0 Then
If err.Number = 5020 Then
MsgBox "The regular expression pattern you provided is malformed." & vbCrLf & vbCrLf & strPattern & _
vbCrLf & vbCrLf & "Please review and correct.", vbCritical + vbOKOnly, "RetrievePMCollection Error"
End If
Set objRegExp = Nothing
Exit Function
End If
On Error GoTo 0
Set objRegExp = Nothing
End If
End Function
<wbr>
I get the error on the function header, which looks to be the problem, but I'm not sure how to resolve this type of thing.
Any help would be appreciated.