Send Data to IE

I cannot supply you code till I am at work tomorrow (12 hours) but yes there is a way to do this. But I need you to tell me how you identify your internet explorer and that it is on the right webpage.

The easiest is the URL (if it does change and is unique) or the title of the HTML document. We need this because Internet Explorer has tabs.

If you can give me unique qualities of the webpage then I will get you something.

Also from the table is this one row the only row you want?

I really appreciate your help! The IE window is identified by the title:

Window1 = FindWindow(vbNullString, "Page Title")

I've tested it and this part of the code does work (makes the window active).

There will be several fields on the page I will send data from Access to, identified by the name of the field:

Me.AccessField1 = IE.Document.All.Item("ui_rateedit_rate1D1").Value
Me.AccessField1 = IE.Document.All.Item("ui_rateedit_rate1D2").Value
Me.AccessField1 = IE.Document.All.Item("ui_rateedit_rate1D3").Value
Me.AccessField1 = IE.Document.All.Item("ui_rateedit_rate1D4").Value

So far I have not run into any fields that do not have a name, so I don't think that will be an issue.
 
I do not think you can use the Findwindow function. Can you show me a screen shot of the top of your window with the webpage open. We need something unique
 
I do not think you can use the Findwindow function. Can you show me a screen shot of the top of your window with the webpage open. We need something unique

It's worked for me... I put the actual page title in the code below and it pulled the page called "Dental Rates" from the task bar, made it active, and maximized it.

Of course, the issue has been integrating the other bit of code to input the data from Access to IE. So, we've got the window open and active... just can't the data from one to the other.

Dim Window1 As Long

Window1 = FindWindow(vbNullString, "Dental Rates")

BringWindowToTop (Window1)
ShowWindow Window1, SW_SHOWMAXIMIZED
 
Here is what I think is the best way to get to the currently open IE and to the webpage on the right tab.

You will have to change this if IE is not open.


The below code prints out the document title and url so that you can see what it is. This is how you can test to make sure you have the right webpage.

Code:
Dim objShellWindows As New SHDocVw.ShellWindows
Dim tempOBJ As Object
Private ieDenRates As SHDocVw.InternetExplorer

Dim titleDenRates As String
Dim urlDenRates As String


titleDenRates = ""
urlDenRates = ""

On Error Resume Next

'loop over all Shell-Windows
For Each tempOBJ In objShellWindows

    'if the document is of type HTMLDocument, it is an IE window
    If TypeName(tempOBJ.Document) = "HTMLDocument" Then
        'check the URL
        Debug.Print "++ TITLE = " & tempOBJ.Document.Title & " - URL = " & tempOBJ.Document.URL
        
        Debug.Print tempOBJ.Document.Title
        
        Debug.Print tempOBJ.Document.URL
        
        If tempOBJ.Document.Title = titleDenRates And tempOBJ.Document.URL = urlDenRates Then
            Debug.Print "++ TITLE = " & tempOBJ.Document.Title & " - URL = " & tempOBJ.Document.URL
            Set ieDenRates = tempOBJ
            Set tempOBJ = Nothing
        End If
    
    End If

Next
 
that is strange I got a notice that you had written something.

You need to set a reference to Microsoft Internet Control
 
that is strange I got a notice that you had written something.

You need to set a reference to Microsoft Internet Control

Sorry, I had and then deleted it; I figured out that's what was wrong. I tinkered around with your code and I'm able to get it to recognize the window and print out the title, URL, etc. Where does the data transfer piece come into play?
 
well provided you are on the right page and provided ieDenRates is an object this will now work.

Code:
Me.AccessField1 = ieDenRates.Document.All.Item("ui_rateedit_rate1D1").Value
 
well provided you are on the right page and provided ieDenRates is an object this will now work.

Code:
Me.AccessField1 = ieDenRates.Document.All.Item("ui_rateedit_rate1D1").Value

I just can't get it to work. When it comes to the data code, it doesn't do anything.

I'm trying to understand why my original code won't work.

Code:
Private Sub Command0_Click()

Dim Window1 As Long

Window1 = FindWindow(vbNullString, "Dental Rates")

BringWindowToTop (Window1)
ShowWindow Window1, SW_SHOWMAXIMIZED

Window1.Document.All.Item("ui_rateedit_rate1D1").Value = Me.DentalDiscQ1F1

End Sub

This works up until the "Window1.Document.All.Item("ui_rateedit_rate1D1").Value = Me.DentalDiscQ1F1" code, where it errors for "Invalid Qualifier". I can get it to pull up the window and make it active, so why can't I get it to transfer the data? I'm about to bang my head against the wall.
 
This works up until the "Window1.Document.All.Item("ui_rateedit_rate1D1").Value = Me.DentalDiscQ1F1" code, where it errors for "Invalid Qualifier". I can get it to pull up the window and make it active, so why can't I get it to transfer the data? I'm about to bang my head against the wall.

because window1 has absolutely nothing to do with the webrowser.

What you are doing in code is like taking the keys to A380 plane and sticking them into a car and saying "CAR FLY"....it aint gonna fly
 
because window1 has absolutely nothing to do with the webrowser.

What you are doing in code is like taking the keys to A380 plane and sticking them into a car and saying "CAR FLY"....it aint gonna fly

Haha... but isn't there SOMETHING we can do to make it fly? I just can't fathom that I have two sets of code that do exactly what I need them to do, but I can't combine them.
 
whilst you have been telling me that you are showing ALL you code, you are not.

FindWindow is a Windows API and somewhere you have this
Code:
Public Declare Function FindWindow Lib “user32″ Alias “FindWindowA” _
    (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long

This finds the handle or a number which uniquely identifies in windows this window. You cannot as far as I know got from this handle to the webbrowser which is actually hosted inside this window.

Work with my code. It is up to you to test and work it out as I do not have access to your website. But based on the html you showed me it works.
 
whilst you have been telling me that you are showing ALL you code, you are not.

FindWindow is a Windows API and somewhere you have this
Code:
Public Declare Function FindWindow Lib “user32″ Alias “FindWindowA” _
    (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
This finds the handle or a number which uniquely identifies in windows this window. You cannot as far as I know got from this handle to the webbrowser which is actually hosted inside this window.

Work with my code. It is up to you to test and work it out as I do not have access to your website. But based on the html you showed me it works.

I FINALLY got it to work with your code! Thank you SO much! Sorry I was a pain... I'm still a VB novice. Thanks again!
 
Hello Darbid,

Your code works for me to find out parts of the IE page.
But i got a page with frames. Is there a possibility to get the innerHTML for those frames

I'm using the following code to get my html
Set ieDenRates = tempOBJ
With tempOBJ.Document.all.Item
ReadHtml = .innerHTML
End With

Do you have a idee.

Lejon
 
Hello Darbid,

Your code works for me to find out parts of the IE page.
But i got a page with frames. Is there a possibility to get the innerHTML for those frames

Hi and Welcome to the forum. Good to see Google is working well.

There are 1 to n frames on the page. Frames start at 0.

Code:
Dim myHTMLFrame1 As HTMLDocument
set myHTMLFrame1 = tempOBJ.Document.Frames(0).Document
This will give you the first frame.
Remember that whilst the webpage might be showing and look good the frames might not be ready for you, so you need to make sure that it is downloaded, and ready for you to get information from it.

Each document has a "Ready" property otherwise you need to catch errors and then try again if the frame does not contain what you know it should.
 

Users who are viewing this thread

Back
Top Bottom