Invalid Procedure / Call Argument on Google API Scraper / Extract Results Function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
4.29K views
0

Hi Folks!

I’m on Windows 10 / 64bit . . .

Working on this all day . .. no luck . . . getting invalid procedure when I get to the “tmp = matches(0).SubMatches(0)” line . . . any ideas? would love to make this work …

‘— begin snippet of code . . . .
Function ExtractResults(res As String) As Collection
Dim resCol As Collection, tmp As String, matches, match, subMatch, GoogleRes As GoogleSearchResult
Set resCol = New Collection
Dim regex As Object, str As String
Set regex = CreateObject(“VBScript.RegExp”)
With regex
.Pattern = “””results””:[([^]]+)]”: .Global = False
End With
Set matches = regex.Execute(res)

‘HERE IS WHERE IT DIES!
tmp = matches(0).SubMatches(0)

With regex
.Pattern = “{([^}]+)}”: .Global = True
End With
Set matches = regex.Execute(tmp)
‘—- end snippet of code

0

The issue may surely be because there are no matches and submatches as a result of your Regex. Be sure to put a break point before the line throwing the error. Check then in the “Locals” VBA Project window if indeed there are any matches and submatches.

edited answer

Simply the best place to learn Excel VBA