Consulting

Results 1 to 12 of 12

Thread: Fill Existing Webpage Fields With Data

  1. #1
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location

    Fill Existing Webpage Fields With Data

    I've got a program I've created to automate a process here at work. One of the tasks I want to automate is for data from an Access Form to automatically populate to textfields in a webpage on Internet Explorer.

    I can do this by bringing up a new webpage with this:

    [vba]Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate "http://zip4.usps.com/zip4/welcome.jsp"
    IE.Visible = True
    While IE.busy
    DoEvents
    Wend
    IE.Document.all("address2").Value = "123 Carraige Way"
    IE.Document.all("city").Value = "Shreveport"
    IE.Document.all("State").Value = "CA"
    IE.Document.all("zip5").Value = "90210"[/vba]

    If you run this code, you'll see that it works perfectly.

    My issue is that I need to populate text to an already exisitng webpage- one that's already open in internet explorer. This is due to the fact that the webpage I need to work with can only be accessed after a user logs into the website, and for security reasons I am not going to automate the login procedure.

    What do I need to adjust so that I can get the above code to focus on an existing page?
    Last edited by CreganTur; 08-08-2008 at 11:16 AM.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Someone at work helped me figure this one out. Here's the code that will interact with an already opened webpage, and will load data into textboxes on the page.

    Here's the code (Requires a reference to Microsoft Internet Controls):

    [vba]Dim ieDoc As Object
    Dim sws As SHDocVw.ShellWindows
    Dim strURL As String
    Dim n As Integer
    'Set main URL to evaluate open IE windows
    strURL = "http://zip4.usps.com/zip4/welcome.jsp"
    Set sws = New SHDocVw.ShellWindows
    'Cycle through all open IE windows and assign the window whose URL matches strURL
    For n = 0 To sws.Count - 1
    If Left(sws.Item(n).LocationURL, Len(strURL)) = strURL Then
    Set ieDoc = sws.Item(n).Document
    sws.Item(n).Visible = True
    Exit For
    End If
    Next n
    ieDoc.all("address2").Value = "123 Carraige Way"
    ieDoc.all("city").Value = "Shreveport"
    ieDoc.all("State").Value = "CA"
    ieDoc.all("zip5").Value = "90210"[/vba]

    But, if someone wants to show another way to accomplish this, please do!
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  3. #3
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    outside the fact you should probably code for the possibility that the ie window is not opened, you seem to have it. If the url were launched by you/VBA ie has an hwnd property so you could use GetObject().

    I'm assuming the url has a submit button and the data input from Access has a return value in which case you could also use 'HTTP Post'.

    .02 Stan

    [edit]
    P.S. - just noticed you State Flag - I'm in Raleigh

  4. #4
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    VBA ie has an hwnd property so you could use GetObject().
    Would the window's handle (hwnd) be the parameter for GetObject()? Would it be evaluated as a string or as number?

    you could also use 'HTTP Post'
    I'm unfamiliar with this- any links you could share?

    P.S. - just noticed you State Flag - I'm in Raleigh
    I'm in Greensboro- small world after all
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  5. #5
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    here is a start

    http://www.mombu.com/microsoft/inter...ba-269443.html

    but it really depends on how expansive your app is, and GetObject() is quite finicky with IE. I wrote an app for the NC Saves SignUp website (which had 14 text and 5 dropdowns). The 'users' never even saw the website. They were small non-profits or Cooperative Extension offices (who didn't even have Microsoft Office). The data was input to a form and saved to an Access Table, using only ADO and fabricated recordsets. Then an Internet connection was checked/detected, a hidden instance of IE was launched and credentials sent, then HTTP Post used to upload data just entered from form. [sorry for the Tangent]

  6. #6
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Thanks man.

    Hey, do you have any idea how to fill in cells in a javascript table? I'm hoping it can be done in a way similar to what I'm doing with filling in the textboxes... because I REALLY don't want to use sendkeys.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  7. #7
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Quote Originally Posted by CreganTur
    Thanks man.

    Hey, do you have any idea how to fill in cells in a javascript table? I'm hoping it can be done in a way similar to what I'm doing with filling in the textboxes... because I REALLY don't want to use sendkeys.
    define 'javascript table' - some backend databases employ java 'grids'; other use pop-up child windows which cannot be handled directly by DHTML, but in a previous thread where I was assisted by Tom Schreiner you can use IE events to get at it.

    In situations like these, hopefully someone from the community reading this can suggest an open url we can use to test code with.

    Stan

  8. #8
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    define 'javascript table'
    Well... first of all I know next to nothing about Java. It may be a Grid. It uses the keyword 'GridProps' in the section where the text of the of the row headers is setup.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  9. #9
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Hard to say, I guess. I deal with a Java Grid on a daily basis, the backend is Cold Fusion, so parsing it involves a whole lot of transforming escape codes. What you can do is save the page locally as an .htm file. I have a freeware compiled exe called IEAnal that extracts DHTML elements and writes code snippets for them.

  10. #10
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    I have a freeware compiled exe called IEAnal that extracts DHTML elements and writes code snippets for them.
    Can you please provide a link for this program?

    NinjaEdit: I found your website via Google (and googling 'IEAnal' brings up some interesting results

    I really hope this will help me be able to work with this webpage.
    Last edited by CreganTur; 08-12-2008 at 05:47 AM.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  11. #11
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Quote Originally Posted by CreganTur
    and googling 'IEAnal' brings up some interesting results
    OMG... did you check out the IEAnalRetentive stuff?

  12. #12
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Quote Originally Posted by stanl
    OMG... did you check out the IEAnalRetentive stuff?
    I'm afraid of what would come up

    I'm starting to wonder if my problems stem from some unusual design on the webpage I'm trying to work with. Either it's using non-standard objects... or I'm just clueless about how to interact with them. Probably the second one
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •