UDF to find Redirect Web Url
Suppose you have the list of web URL's which are redirecting to new URL. To find the redirect/ new URL try this UDF-
Function redirect_url(surl As String) As String
Dim myIE As Object
Set myIE = CreateObject("InternetExplorer.Application")
myIE.Navigate surl
Do While myIE.Busy
Loop
redirect_url = myIE.Document.URL
myIE.Quit
Set myIE = Nothing
End Function
»
- Ashish Koul's blog
- Login or register to post comments
- 6528 reads
I am trying to capture the
I am trying to capture the redirected URL, with the following piece of code, but the code fails @ "redirurl = myIE.Document.URL" with "Run Time Error '-2147467259 (80004005) Method 'Document' of Object 'IWebBrowser2' Failed" error. Could you pls help me, how to fix the issue.
Dim myIE As Object
Dim redirurl As String
Set myIE = CreateObject("InternetExplorer.Application")
myIE.Visible = True
myIE.Navigate
Do While myIE.Busy
Loop
'This below piece of code throwing me the runtime error
redirurl = myIE.Document.URL
Dear Ashish,I used this
Dear Ashish,
I used this piece of code to capture the redirected URL, but the code fails @ "redirUrl = myIE.Document.URL" and with following error. Can you please let me know, how to fix this issue?
"Run Time Error '-2147467259 (80004005)
Method 'Document' of Object 'IWebBrowser2' Failed"