Send Data to IE

brett429

Registered User.
Local time
Today, 18:03
Joined
Apr 3, 2008
Messages
114
Ok, so I'm trying to combine code from two different sources to get this to work right. What I'm doing is calling a specific IE window, making it active, and then sending data from the field on my Access form to the field on the website.

The first part works fine, but I cannot get the data to feed over (see bold section). When I was using this with another bit of sendkeys code, it worked fine. I realize the "IE" part won't work because there's no object called "IE," but I've tried swapping that out with other things and nothing works. HELP!

Private Sub Command0_Click()
Dim Window1 As Long

Window1 = FindWindow(vbNullString, "IE Document Title")

BringWindowToTop (Window1)
ShowWindow Window1, SW_SHOWMAXIMIZED

IE.Document.All.Item("WebFieldName").Value = Me.AccessFieldName

Command0_Exit:
End Sub
 
You could try:
Code:
Private Function GetWebPath() As String

    GetWebPath = "http://" & Forms![Menu]![Web Site]

End Function

Then:

Code:
Function Web_Galleries()

        Dim WebLink As String
        WebLink = GetWebPath
        Application.FollowHyperlink WebLink, , True
        HideWebToolBar

End Function
Simon
 
You could try:
Code:
Private Function GetWebPath() As String

    GetWebPath = "http://" & Forms![Menu]![Web Site]

End Function
Then:

Code:
Function Web_Galleries()

        Dim WebLink As String
        WebLink = GetWebPath
        Application.FollowHyperlink WebLink, , True
        HideWebToolBar

End Function
Simon

Thanks for the response! I'm not sure how to implement your code or what it's intended to do. Based off the first piece, it looks like I'd be required to have the URL on the form, but I do not want that. I need it to find the window that is already open based off the title (the code I have for this already works). What I cannot get to work is, once it finds the window, sending the data from the form to IE.
 
don't you have to set a variable to the ie object? if you already have code that identifies the ie program in a window, then it should be set already. if it's set correctly, I would assume all you'd have to do is use the DOM controls of that webpage to send the value up.

do you have any knowledge of the DOM?
 
don't you have to set a variable to the ie object? if you already have code that identifies the ie program in a window, then it should be set already. if it's set correctly, I would assume all you'd have to do is use the DOM controls of that webpage to send the value up.

do you have any knowledge of the DOM?

Hmmm, that's Greek to me. The code I put in my original post is what I have. Originally I used the code below, which does successfully transfer data from the Access form to IE. The problem with this code is that it requires a URL, which I did not want. I want it to find a window already open and use that. So I found code that did that, but then the transfer data code didn't work. I need to find a way to combine the two.

Set IE = CreateObject("InternetExplorer.Application")

IE.Navigate IE.Visible = True While IE.Busy D...em("WebFieldName").Value = Me.AccessFieldName
 
IE.Document.All.Item("WebFieldName").Value = Me.AccessFieldName

The url is the best way to help you if the above is your problem.

How about copying the source html from this page and putting it into a text file and uploading it here?
 
The url is the best way to help you if the above is your problem.

How about copying the source html from this page and putting it into a text file and uploading it here?

The URL changes, though. That's why I have it based off the name of the window, because that is always the same.
 
buddy you are losing me.

  1. Please show your full code
  2. Please indicate in that full code exactly where you have a problem
  3. If your problem relates to data being entered into a control located on a webpage then please do the following;
  4. open to the URL and right click on the webpage
  5. choose something like view source
  6. save the resulting text you see as a simple txt file and upload it
  7. Then describe the control as you see it on the webpage so that I/we can find it in the html text.
 
buddy you are losing me.

  1. Please show your full code
  2. Please indicate in that full code exactly where you have a problem
  3. If your problem relates to data being entered into a control located on a webpage then please do the following;
  4. open to the URL and right click on the webpage
  5. choose something like view source
  6. save the resulting text you see as a simple txt file and upload it
  7. Then describe the control as you see it on the webpage so that I/we can find it in the html text.

Sorry for the confusion. I'll try to explain it a different way. Basically, I have two sets of code that perform two different functions. Each set of code works properly by itself, but what I am trying to do is combine parts of BOTH to perform a specific function.

CODE 1 - This code successfully opens IE, goes to a specific URL, looks up the values of HTML fields ("ui_rateedit_rate1D1", etc. in the code) and then copies them back to my Access fields ("Me.AccessField1", etc. in the code).

Private Sub CommandButton_Click()

Set IE = CreateObject("InternetExplorer.Application")

IE.Navigate "http://www.url.com"
IE.Visible = True

While IE.Busy
DoEvents
Wend

IE.Document.All.Item("ui_rateedit_rate1D1").Value = Me.AccessField1
IE.Document.All.Item("ui_rateedit_rate2D1").Value = Me.AccessField2
IE.Document.All.Item("ui_rateedit_rate3D1").Value = Me.AccessField3
IE.Document.All.Item("ui_rateedit_rate4D1").Value = Me.AccessField4

End Sub


CODE 2 - This code successfully locates an IE window that is already open and makes it active; based off the IE window title ("Website Title" in the code)
Private Sub CommandButton_Click()

Dim Window1 As Long

Window1 = FindWindow(vbNullString, "Website Title")

BringWindowToTop (Window1)
ShowWindow Window1, SW_SHOWMAXIMIZED

End Sub


Code 3 (What I Need) - I need code that will find an open IE window based off the TITLE, make it active (Code 2) and then copy the values from specific HTML fields in IE to Access fields (Code 1).

I've managed to get "sendkeys" to work with Code 2, but I don't want to go that route, because you have to navigate the IE screen using tabs and such (incredibly sketchy). I'd much rather use the field-specific features of Code 1.
 
[/B]I've managed to get "sendkeys" to work with Code 2, but I don't want to go that route, because you have to navigate the IE screen using tabs and such (incredibly sketchy). I'd much rather use the field-specific features of Code 1.

Right so your problem lies here. can you supply the html text from this page by doing 4 to 7 in my last post.
 
Right so your problem lies here. can you supply the html text from this page by doing 4 to 7 in my last post.

Here's the exact section of HTML that I'd be getting the data from:

<TD align="right">Monthly Rate:</TD><TD><input size="15" name="ui_rateedit_rate1D1" class="RatesTableData" type="text" value="29.57"/></TD><TD><input size="15" class="RatesTableData" type="text" name="ui_rateedit_rate2D1" value="57.42"/></TD><TD><input class="RatesTableData" size="15" type="text" name="ui_rateedit_rate3D1" value="67.97"/></TD><TD><input class="RatesTableData" size="15" type="text" name="ui_rateedit_rate4D1" value="95.82"/></TD></TR>
 
Can you at least supply the whole table.
 
Here's the exact section of HTML that I'd be getting the data from:

<TD align="right">Monthly Rate:</TD><TD><input size="15" name="ui_rateedit_rate1D1" class="RatesTableData" type="text" value="29.57"/></TD><TD><input size="15" class="RatesTableData" type="text" name="ui_rateedit_rate2D1" value="57.42"/></TD><TD><input class="RatesTableData" size="15" type="text" name="ui_rateedit_rate3D1" value="67.97"/></TD><TD><input class="RatesTableData" size="15" type="text" name="ui_rateedit_rate4D1" value="95.82"/></TD></TR>

If you want data from this then you already have this

Code:
[SIZE=2]Me.AccessField1 = [/SIZE][SIZE=2]IE.Document.All.Item("ui_rateedit_rate1D1").Value[/SIZE]
This will work for any of the cells in the table PROVIDED they are named for you.
 
If you want data from this then you already have this

Code:
[SIZE=2]Me.AccessField1 = [/SIZE][SIZE=2]IE.Document.All.Item("ui_rateedit_rate1D1").Value[/SIZE]
This will work for any of the cells in the table PROVIDED they are named for you.

Using the following code, I get this error: 424 Object Required

Private Sub CommandButton_Click()

Dim Window1 As Long

Window1 = FindWindow(vbNullString, "Page Title")

BringWindowToTop (Window1)
ShowWindow Window1, SW_SHOWMAXIMIZED

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

End Sub

Using the following code, I get this error: Method 'Document' of object "IWebBrowser2" failed.

Private Sub CommandButton_Click()

Dim Window1 As Long

Window1 = FindWindow(vbNullString, "Page Title")

BringWindowToTop (Window1)
ShowWindow Window1, SW_SHOWMAXIMIZED

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

While IE.Busy
DoEvents
Wend

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

End Sub
 
Window1 = FindWindow(vbNullString, "Page Title")

You are not showing full code which kinda makes it hard. But this appears to be a Windows API to get a window handle?????

Set IE = CreateObject("InternetExplorer.Application")

Here you set a new object IE from the creation of a NEW Internet Explorer. WHY? You realize that this IE object has no connection with your window1.

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

Thus this line is never going to work if your html page is in Window1 and you are using a new IE explorer window.
 
You are not showing full code which kinda makes it hard. But this appears to be a Windows API to get a window handle?????



Here you set a new object IE from the creation of a NEW Internet Explorer. WHY? You realize that this IE object has no connection with your window1.



Thus this line is never going to work if your html page is in Window1 and you are using a new IE explorer window.

That is the full code. I know that the coding to create a new IE window doesn't belong, but when I remove it, I get the "Object required" error. The code you'd suggested makes reference to the IE object:

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

Do you see any way to change the code to make it work?
 
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?
 

Users who are viewing this thread

Back
Top Bottom