' VBA macro to open in Internet Explorer the URL found in an Excel cell when a cell in Column D Reference must be set in VBA: Tools -> References. Also, for the macro to work, the Microsoft Internet Controls In the macro commentary, the algorithm used to select an Internet Explorer tab rests on the somewhat precarious assumption that each tab title is unique within the Internet Explorer session. The VBA macro is invoked whenever a user double-clicks on a cell in the worksheet with which the macro is associated.
#Vba internet explorer document professional#
18702CO on Windows XP Professional Version 2002 SP3. SP3 with Visual Basic 6.5 and Internet Explorer Version. I did find some suggetions that it would be necessary to use SendKeys to make a particular tab active.
#Vba internet explorer document how to#
And I couldn't find much explaining how to use IAccessible and didn't find anythingĮxplaining how to use IAccessible to make a particular Internet Explorer tab active. A fairly thorough search of the Internet did not surface an answer to your question. It is surprising to me that your question went unanswered for months in this forum. Would we have to use an IAccessible object? I've looked everywhere and can't find anything. How do I activate the internet explorer tab that belongs to the IE object? SetForegroundWindow IE.hwnd 'activeate the IE windowīut if the captured IE object represents an inactive tab, the above only brings the IE main window into focus. ShowWindow IE.hwnd, SW_RESTORE 'restore the window End If If CBool(IsIconic(IE.hwnd)) Then 'if window is minimized. With the following code, to check if IE is minimized: Private Declare Function IsIconic Lib "user32.dll" (ByVal hwnd As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Const SW_SHOWNORMAL = 1 Private Const SW_MAXIMIZE = 3 Private Const SW_SHOW = 5 Private Const SW_MINIMIZE = 6 Private Const SW_RESTORE = 9 Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long We can then use the following declarations: We can find an existing instance of IE with a certain page loaded. ' Dim objShell As Object, objShellWindows As Object, o As Object Dim retVal As Object, sURL As String Set retVal = Nothing Set objShell = CreateObject("Shell.Application") Set objShellWindows = objShell.Windows For Each o In objShellWindows sURL = "" On Error Resume Next sURL = o.Document.Location On Error GoTo 0 If sURL "" Then If sURL Like sAddress & "*" Then Set retVal = o Exit For End If End If Next o Set GetIE = retVal End Function Function GetIE(sAddress As String) As Object ' Find an IE window with a matching (partial) URL.