Hi to all,
I have the following problem: I have found some code on the web regarding the use of automating IE using VBA. However, as far as I understand the code has been written for a Class Module (I think). The code is below
(I have left the Class name as Class1)
Option Explicit
Public WithEvents ie1 As InternetExplorer
Public ie2 As InternetExplorer
Private Declare Sub Sleep Lib "kernel32" ( _
ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Set ie1 = CreateObject("InternetExplorer.Application")
ie1.Visible = True
ie1.Navigate2 "http://www.yahoo.com"
While ie1.ReadyState < READYSTATE_COMPLETE
Sleep 100
Debug.Print "ie1 busy"
Wend
Debug.Print ie1.LocationURL & "AA"
ie1.Navigate2 "http://www.google.com", 1
While ie2.ReadyState < READYSTATE_COMPLETE
Sleep 100
Debug.Print "ie2 busy"
Wend
Debug.Print ie2.LocationURL & "BB"
End Sub
Private Sub ie1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set ie2 = CreateObject("InternetExplorer.Application")
Set ppDisp = ie2.Application
Debug.Print "NewWindow2"
End Sub
My question is: How can I use this code ??
So far I have tried the following (Set up the code in a standard module)
Option Explicit
Dim IEobject As New Class1
Public Sub Test_Class1()
Set IEobject1.ie1 = InternetExplorer
End Sub
However I get the error:
Compile Error: Variable not defined
I am desperate for any help.
gauss1976
Bookmarks