excel vba httprequest capture last redirect url RRS feed

  • General discussion

  • Hi,

    I am trying to capture the last URL from a bunch of redirected URLs using excel VBA. Can someone please help.

    Here is my code. 
    Function GetURL(url As String)
        Dim request As New WinHTTP.WinHttpRequest
        request.Option(WinHttpRequestOption_EnableRedirects) = True
        request.Open "HEAD", url, False
        If Not request.Option(1) = "" Then
            GetURL = request.Option(1)
            GetURL = url
        End If
    End Function

    This code only returns the first redirected URL. I am not sure what did I miss.

    Example: redirects to redirects to

    GetURL("") gives result --

    Desired result is
    Friday, March 31, 2017 5:02 AM

All replies