Web pages that use input from user.

I have written a program that keeps track of tracking numbers for several different trucking lines. What I would like to do is be able to highlight a tracking number and let the user click a button to track that shipment online. I have all of that working but many of the web sites show addresses like this:

http://www.myyellow.com/dynamic/services/servlet

I have 2 trucking lines web sites that work because the address to their web page shows the tracking number right in the address so all I have done is open internet explorer and tell it to go to that web page but I put whatever tracking number I want in there.

So my question is, is there a way to pass the tracking number to a web site like the one above? Do they maybe use an address that has the tracking number imbedded in it but is hidden that I could find? Thanks for any help.

J_K_M_A_N
LVL 3
J_K_M_A_NAsked:
Who is Participating?
 
edwardiiiCommented:
Hi, J_K_M_A_N.

I've set up a routine that grabs an open IE window, populates various Text input fields in the Web page with values, and clicks the "Submit" button on that page.  Getting the names of the textboxes is the key; you can do it by setting a textbox equal to the following type code and cycling through all possible values, or you can do a "View Source" of the target Web page and grab the pertinent "name=" values:

Text1.Text = "Name is: " & internetExplorerWin.Application.Document.Forms(2).Elements("tracknum").Name _
    & " Value is: " & internetExplorerWin.Application.Document.Forms(2).Elements(3).Value

To do what you want to do, tell IE to go to such a page (I wasn't able to use your Yellow Freight page because I didn't have time to set up a user account--the example below deals with the UPS tracking page at http://www.ups.com/content/us/en/index.jsx).  Then run the following code once the IE window has been opened:

    Dim objInternetExplorerShellWindows As Object
    Dim internetExplorerWin As Object
    Dim strBrowserCaption As String
 
    strBrowserCaption = "Welcome to UPS"
     
    Set objInternetExplorerShell = CreateObject("Shell.Application")
    Set objInternetExplorerShellWindows = objInternetExplorerShell.Windows
 
     For Each internetExplorerWin In objInternetExplorerShellWindows
          On Error Resume Next
         
          If internetExplorerWin.Application.Document.Title = strBrowserCaption Then
               
               internetExplorerWin.Application.Document.Forms(2).Elements(3).Value = "111111Test"
               internetExplorerWin.Application.Document.Form(2).Elements(4).Click
               internetExplorerWin.Application.Document.Forms(2).Submit
               
                Text1.Text = "Name is: " & internetExplorerWin.Application.Document.Forms(2).Elements("tracknum").Name _
                & " Value is: " & internetExplorerWin.Application.Document.Forms(2).Elements(3).Value
               
          End If
         
          If Err Then
              Err.Clear
          End If
 
     Next
 
     Set internetExplorerWin = Nothing
     Set objInternetExplorerShellWindows = Nothing
     Set objInternetExplorerShell = Nothing
0
 
J_K_M_A_NAuthor Commented:
OK. I am a little lost. I think I understand what you are doing but you said to find out what the name value is. I don't see where you use that. I believe I have the name value for the tracking number and the go button they use. (BTW, you don't need to sign up for an account. It is at the top of every page on their site.) I believe the name is FBNUMBERS and the name of the button is I4. How would I go about using that. Also, I would like to just open an internet explorer window to their home page and fill in the info and click go. Can I do the first part before it is visible? I am thinking I would just load the page fill in the info and click go THEN give the visible=true command. Would that work?

Thanks for the help. I think we are on the right track. :)

J_K_M_A_N


0
 
J_K_M_A_NAuthor Commented:
OK. After much messing around, I think I have it. I had to set forms(2) = forms(0) and then I set Elements("FBNUMBERS") and it works. I also figured out how to tell it what form to use. Thanks again for the help. I am giving you the points.


J_K_M_A_N
0
 
edwardiiiCommented:
Sorry for not getting back to you earlier, J_K_M_A_N.  Am at UC Irvine until late on Wednesdays.  Glad the code helped:)
0
 
J_K_M_A_NAuthor Commented:
Well EdwardIII, I hope you are still getting e-mail about this thread because I have a question for you. This is the code I am using that has worked for a few other sites but not on one or two of them. Can you look at it and see if I have something wrong? Thanks.


Dim IEo As InternetExplorer
Dim IEWin As Object
Dim IEShell As Object

Set IEo = CreateObject("InternetExplorer.Application")
IEo.Navigate2 "http://www.speedeedelivery.com/pod.html"

Do While IEo.ReadyState <> READYSTATE_COMPLETE
    DoEvents
Loop
IEo.Visible = True

Set IEShell = CreateObject("Shell.Application")
Set IEShell = IEShell.Windows

For Each IEWin In IEShell
    On Error Resume Next
   
    If IEWin.Application.Document.Title = "Spee-Dee Delivery - Proof of Delivery" Then
        IEWin.Application.Document.Forms("login_form").Elements("shipperno").Value = "Shipper No"
        IEWin.Application.Document.Forms("login_form").Elements("login_password").Value = "password"
        IEWin.Application.Document.Forms("login_form").Submit

    End If
   
    If Err Then
        Err.Clear
    End If
Next

Set IEo = Nothing
Set IEWin = Nothing
Set IEShell = Nothing


It opens the site but doesn't fill anything in and doesn't submit the form. Any ideas?

Thanks..
J_K_M_A_N
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.