Solved

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

Posted on 2006-07-03
5
441 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need VBS version of Excel date conversion 4 70
Problem to skip loop 6 57
Getting warning: You are about to delete 1 row(s) 9 48
VB6 - Scroll Mouse wheel on Picturebox 13 44
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

770 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