I am using Winhttp in the following VBA code and can't get the URL to work, yet if I paste the URL into a browser it works fine. Any ideas would be appreciated:
Sub WinHttp()
Dim arr() As String
Dim pos As Integer
Dim used As Range
Dim url, resp As String
Dim req As New WinHttpRequest
Dim n As Integer
r = ActiveSheet.UsedRange.Rows.Count
For n = 4 To r
Worksheets("Sheet0").Activate
pn = Cells(n, 2).Value
UnitPrice = (Cells(n, 4).Value) * 1
url = "https://www.google.com/search?q=DNR-12-1G+$4,250"
req.Open "GET", url, False
req.send
resp = req.ResponseText
Debug.Print resp
arr = split(resp)
arr = Filter(arr, "$")
Next n
End Sub
Thanks! It appears the "req.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
Does the trick.