Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-11-2015, 12:12 PM
souravkp souravkp is offline Capturing Redirected URL with macro Windows 7 32bit Capturing Redirected URL with macro Office 2007
Novice
Capturing Redirected URL with macro
 
Join Date: Jul 2015
Location: India
Posts: 1
souravkp is on a distinguished road
Default Capturing Redirected URL with macro

I am trying to capture the redirected URL with Excel Macro, but during run time, this piece of code giving me a run time error (Run-time error '-2147467259 (80004005)':Method 'Document' of object 'IWebBrowser2' failed). Could some one please help me whats wrong with this code and how to fix this issue.



Dim myIE as Object
Dim redURL as String

Set myIE = CreateObject("InternetExplorer.Application")
myIE.visible = True
myIE.Navigate <URL1>

Do While myIE.Busy
Loop

'This is where I am getting the Run time error.
'Run-time error '-2147467259 (80004005)':Method 'Document' of object 'IWebBrowser2' failed
redURL = myIE.Document.URL
Reply With Quote
  #2  
Old 07-11-2015, 09:34 PM
gmayor's Avatar
gmayor gmayor is offline Capturing Redirected URL with macro Windows 7 64bit Capturing Redirected URL with macro Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The error appears to relate to the macro trying and failing to open a second instance of IE. Try the following instead
Code:
Dim myIE As Object
Dim redURL As String
    redURL = "http://www.gmayor.com/Word_pages.htm"
    On Error Resume Next
    Set myIE = GetObject(, "InternetExplorer.Application")
    If Err Then
        Set myIE = CreateObject("InternetExplorer.Application")
    End If
    On Error GoTo 0
    myIE.Visible = True
    myIE.Navigate redURL

    Do While myIE.Busy
    Loop
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
macro, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing Redirected URL with macro Capturing numbered headings jbvalen Word VBA 5 05-04-2017 05:03 PM
custom icon, undo/redo for macro, permanent macro Rapier Excel 0 08-05-2013 06:30 AM
email being redirected to a user not on list of users to be sent to sjvjoe Outlook 0 09-26-2012 12:42 PM
Capturing Redirected URL with macro Capturing addresses into contacts lordnacho Outlook 1 11-01-2010 06:05 PM
time capturing aligahk06 Excel 0 04-18-2010 11:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft