shahin
Active Member
Hi there!! This is my first ever attempt to work with regex which is supposed to be applied on "responsetext" to find any phone number from a webpage. As I never used regex within vba, I'm not at all sure what I did in my below script is at all permissible cause I found it from a site and tried to clone the usage of it. However, it throws an error "run time error 5" "invalid procedure call or argument".
Script I tried with:
One more thing: i tried to use here (Regex) late binding. It would be awesome if i get any hint how to do it using early binding as well. Thanks in advance. Btw, the credit for the regex pattern goes to me lol!!
Script I tried with:
Code:
Sub requests_with_regex()
Dim IE As New InternetExplorer, html As New HTMLDocument
With IE
.Visible = True
.navigate "http://www.peekayfarmequipments.com/enquiry.html"
Do Until .readyState = READYSTATE_COMPLETE: Loop
Set html = .document
End With
With CreateObject("VBScript.RegExp")
.Pattern = "\+?\d+.-?\(?\d+.\)?-?\s?\w*.-?\s?\w*."
r = r + 1: Cells(r, 1) = .Execute(html).Item(0).SubMatches(0) ''error thrown here
End With
IE.Quit
End Sub
One more thing: i tried to use here (Regex) late binding. It would be awesome if i get any hint how to do it using early binding as well. Thanks in advance. Btw, the credit for the regex pattern goes to me lol!!