Help with existing code

kyndsi

New Member
Joined
Feb 16, 2018
Messages
16
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...

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.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Do you have anything defined/declared with the name MatchCollection?

How about something called udeRetrievePMCollection_OPTIONS?
 
Upvote 0
That's where I'm getting lost. Those don't appear to be native VBA variable types, and I don't know how to go about defining them.

Am I missing an external library?
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top