I am using regular expressions in a file that I have been using for a few years, and today I am suddenly getting a "Permission denied" error on this line:
Function RegExpFind(FindIn As String, _
FindWhat As String, _
Optional IgnoreCase As Boolean = False) As Variant ' returns an array of all matches
Dim i As Long
Dim RE As Object, allMatches As Object, aMatch As Object
Set RE = CreateObject("vbscript.regexp")
RE.Pattern = FindWhat
RE.IgnoreCase = IgnoreCase
RE.Global = True
Set allMatches = RE.Execute(FindIn)
If allMatches.Count >= 1 Then
ReDim rslt(0 To allMatches.Count - 1)
For i = 0 To allMatches.Count - 1
rslt(i) = allMatches(i).Value
Next i
RegExpFind = rslt
End If
End Function
I have not changed any code in the file or settings in Excel. This occurred the first time I ran this following a reboot, which was required to implement an update to Malwarebytes. As far as I can tell there were no Windows or Microsoft Office updates applied during this reboot.
I searched extensively and this problem seems to have occurred in the past following a Windows security patch, but I could not find anything more recent than about three years old.
EDIT: I changed to early binding with a reference to the RegExp library and get the same error when instantiating the object:
Dim RE As RegExp
Dim allMatches As Object, aMatch As Object
Set RE = New RegExp ' Same error here
pderror.jpg
pdcode.JPG
Bookmarks