-1

Is there a way to copy the request Url into Excel using VBA. The code i use at the moment copies the Location Url into Excel. But i really need the request Url. This Url you can find using Developer tools in Internet Explorer and look at Network.

My code right now:

Sub GetUrl()
    Const READYSTATE_COMPLETE As Long = 4
    Dim IE As Object

    Set IE = CreateObject("InternetExplorer.Application")

    IE.Navigate Cells(1, 1).Value

    '// Wait for page to finish loading
    While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE
    DoEvents
    Wend

    Cells(1, 10).Value = IE.LocationURL
End Sub
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73

1 Answers1

0

What's the different between the Cells(1,1).Value and the request URL, if they are same, there is no need to get the request URL from IE browser, just copy the value and paste to another cell.

If you want to get the request URL, as a workaround, I suggest you could add a hidden file in your web page, and use it to store the request URL (when page loading, using JavaScript to set the value), then, you could use the VBA script to find this element and get the value.

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
  • The difference between them is Cell 1,1 is 192.168.10.250 with this url he does his login in the equipment and then the equipment response with a request url but this request url i can only see in the Network tab of the Developer tools from internet explorer and is not the location url. – Y Bisschoff Sep 20 '19 at 10:38
  • As I said, as a workaround, you could use [JavaScript script to get the request url](https://stackoverflow.com/questions/406192/get-current-url-with-jquery), then use a hidden field to store the url, then, we could use the VBA getElements method to find this field and get the url. – Zhi Lv Sep 23 '19 at 09:32