-
I need to use GetObject so that I can use MyIE object to navigate. My objective is to detect the current IE homepage 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.
The key question here is how do I detect IE instances using GetObject?
Below is a little bit detail of my 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
-
Here's your problem, you have an error, that is why you keep getting the "IE Not Found" message.
Code:
'Here is your error
Set MyIE = GetObject([error is right here], "InternetExplorer.Application")
Here is your code fixed, I don't know how to detect IE, but the code opens it no matter what.
Code:
Private Sub OpenIE()
Dim MyIE As Object
Set MyIE = GetObject("", "InternetExplorer.Application")
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
End Sub
Private Sub Form_Load()
OpenIE
End Sub