Solved

Such a thing as "Set objIE = CURRENT InternetExplorer" or something equivalent?

Posted on 2006-07-03
5
437 Views
Last Modified: 2008-02-01
Through use of the code below, VB successfully waits for a page with frames to finish loading. While still in the same public sub, if I wanted to navigate to another link I would use the same bit of code minus the first line 'Set objIE'. My problem is that my code sprouts off to another public sub and when I try to tell IE to navigate some where else using the code below minus the first line "Set objIE = New INternetExplorer" I end up getting a 'Runtime error 424 - object required'.

So I insert the first line "Set objIE = New InternetExplorer" and another (not visible) instance of IE sprouts and navigates to the location. I don't want another instance of IE loading, visible or not. I don't want to close out the IE window since that will cause me to have to log back into the webpage. I even tried "Set objIE = InternetExplorer" WITHOUT the 'New' so I could keep using the existing IE window but VB didn't seem to like that idea.  I've tried to search for some word to use that would mean "Current" instead of "New" but I can't find anything.



    Set objIE = New InternetExplorer
    objIE.Visible = True
    objIE.navigate "http://www.yourpage.com"
    While objIE.readyState <> READYSTATE_COMPLETE
        DoEvents
    Wend
    Dim objHTML As HTMLDocument
    Set objHTML = objIE.document
    While objHTML.readyState <> "complete"
        DoEvents
    Wend


0
Comment
Question by:JohnDoeSr
  • 4
5 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 250 total points
ID: 17034170
you just need to pass the reference to objIE then just

objIE.navigate "http://www.yourpage.com"
    While objIE.readyState <> READYSTATE_COMPLETE
        DoEvents
    Wend
    Dim objHTML As HTMLDocument
    Set objHTML = objIE.document
    While objHTML.readyState <> "complete"
        DoEvents
    Wend
0
 

Author Comment

by:JohnDoeSr
ID: 17034177
How do I pass the reference to objIE? I've only inserted the code above in another public sub and I get a Runtime Error 424 - object required.
0
 

Author Comment

by:JohnDoeSr
ID: 17034224
I'm not sure if it's correct but I've tried passing reference to objIE by doing the following:
Sub Login(ByRef objIE As Object)

The problem is that Sub Login is not called by Sub Form, but instead by a Menu item click. I'm not sure how this will stir things up. I have an Open module opened, but I don't think it can be used in this case.
0
 

Author Comment

by:JohnDoeSr
ID: 17034247
Oh, Sub Form_Load is where the Set ObjIE = new internetexplorer   line is.
0
 

Author Comment

by:JohnDoeSr
ID: 17034540
Looks like sticking

Public objIE As Object

in the module did the trick.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now