-
I need to use GetObject so that I can detect the current IE instance which is already open by the user, save the page and go back to the previous page, put password etc. But my prog can't detect IE instance even though it is running(already open).
The key question here is how do I detect IE instances using GetObject? Thank you.
[code]
Sub DetectIE()
Dim MyIE As Object
On Error GoTo NoIE
Set MyIE = GetObject(, "InternetExplorer.Application")
MsgBox "IE found"
MyIE.Visible = True
MyIE.Navigate "https://www.tm.net.my"
Do Until MyIE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Put login name and password
'Call Authenticate
Do Until MyIE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Copy something to the homepage from Excel
'Call CopyAllAtOnce
Exit Sub
NoIE:
MsgBox "IE not found"
End Sub
-
GetObject will create a new instance of IE. If you want to access an existing instance you could use the Windows API to get the window class of IE, get a reference to the instance using the Window class, and use SendKeys (or an API call) to manipulate the window.