[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Web pages that use input from user. Part 2.

Posted on 2005-04-13
14
Medium Priority
?
281 Views
Last Modified: 2012-05-05
I had asked a question here:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21378895.html

That solution worked for many web pages but I am having a problem with a few. Like the one below. It will open the page but it won't fill in any info. Am I doing something wrong? Is there some other code I should be using instead? Thanks for any help.



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
Comment
Question by:J_K_M_A_N
  • 8
  • 4
  • 2
14 Comments
 
LVL 9

Expert Comment

by:sk33v3
ID: 13773539
Does the if statement fire? All of the statement look correct. Have you tried putting in a stop where the if statement fires to see exactly what the .title variable is actually holding?
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13773612
Looking at the page you are getting. The problem appears to be with the IFrame. In IE open the page and then view source. You will notice that the form fields you are looking for are actually in a frame. Let me see If I can Get you something that will overcome this frame issue.
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13773642
IEWin.Application.Document.Item("iframe1").forms("login_form").Elements("shipperno").Value = "Shipper No"
        IEWin.Application.Document.Item("iframe1").Forms("login_form").Elements("login_password").Value = "password"
        IEWin.Application.Document.Item("iframe1").Forms("login_form").Submit


Can you try something like this?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Author Comment

by:J_K_M_A_N
ID: 13774387
Nope. The Item("iFrame1") gets nothing either. I figure it is something like that though. I just can't seem to find it. Another thing I have tried was something like
IEWin.Application.Document.Forms("all").Elements("shipperno").Value = "Shipper Number"
or something like that. It was suppost to fill in ALL of the "shipperno" fields in ALL forms. That didn't work either. Thanks for the try though. Any other ideas?

J_K_M_A_N
0
 
LVL 9

Assisted Solution

by:sk33v3
sk33v3 earned 120 total points
ID: 13774417
Well it isn't working because of how Iframes work. Technically speaking the iframe is not part of the webpage that you are viewing. So to try and retreive the form from an iframe is such a manner is not going to work. You actually have to target the iframe let me see if I can find something on that.
0
 
LVL 10

Accepted Solution

by:
edwardiii earned 280 total points
ID: 13774442
Hi, J_K_M_A_N.

Sorry about not getting to you sooner.  I travel alot, and when I do rarely check my home emails, which my EE account is tied to.  I was able to get this to work with some sleuthing.  sk33v3 is correct in that the form we want to use for tracking is separated from the "http://www.speedeedelivery.com/pod.html" site.  If you do a "View Source" (right-click on the "Spee-Dee Proof of Delivery allows..." text) of that Web page and then do a CTRL-F for "tracking", you'll see this line:

                                                                  <b>If you experience problems viewing your packages please click <a href="http://12.27.47.198/login.asp" target="_blank">here</a> to open the tracking program in a new..."

The reason your code won't work is it is searching the "www.speedeedelivery.com" Web page when the userform is housed at "http://12.27.47.198/login.asp".  For some reason this login.asp Web page doesn't present a Document.Title, so  I had to alter:

     If IEWin.Application.Document.Title = "Spee-Dee Delivery - Proof of Delivery" Then

to:

     If IEWin.Application.Document.Title = "" Then

This "" page happened to be the only one on my desktop that had no Document.Title, but if we have to we can alter that If statement to something like:

     If IEWin.Application.Document.Title = "" And IEWin.Application.Document.Forms("login_form").Elements(1).Name = "shipperno" Then...

Anyway, using the following filled in your Shipper Number and Password and submitted the form:

     IEWin.Application.Document.Forms("login_form").Elements("shipperno").Value = "12345"
     IEWin.Application.Document.Forms("login_form").Elements("login_password").Value = "MyPassWord"
     IEWin.Application.Document.Forms("login_form").Submit

Bear in mind you can also hunt for Forms and Elements with numbers, such as:
     IEWin.Application.Document.Forms(0).Elements(1).Value = "12345"

Hope this helps.  The key is sometimes a lot of digging through a Web page's HTML code will be required for you to control its forms:)

   


0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13774468
Good job edward. I didn't even see that if your having problems line.
0
 
LVL 3

Author Comment

by:J_K_M_A_N
ID: 13774587
Well, Thanks again Edward. Now I can give you more points. :)

I was looking through the HTML but I didn't pay ENOUGH attention to the main frames code. I was looking more at the login page code. What is funny is that if I had clicked on that, I can just pass the info directly in the address bar. I don't really need to control it this way.

I do feel like I should split the points somewhat though. sk33v3 did put in some work to help. I hope you don't mind. Thanks again for the help.

J_K_M_A_N
0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13774646
I don't mind at all.  Am always glad when members work to help answer questions, and sk33v3 was well on the way to finding the solution:)
0
 
LVL 3

Author Comment

by:J_K_M_A_N
ID: 13774663
One thing though, did you say it works for you if you change it to title = "" in the framed page? Mine doesn't. It does work just fine if I use the other link though which I will probably do. I was just curious.

J_K_M_A_N
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13775726
Well no it won't it will only work for that one page if you browse directly to the url that the frame contains. That page happens not to have a title.
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13775729
BTW thanks for the points
0
 
LVL 3

Author Comment

by:J_K_M_A_N
ID: 13776375
No problem. So what you are saying is, if it had a title, it MAY work in the frame? Would the code see the page in the frame as a seperate page? Because it looks for seperate instances of Internet Explorer so I was just wondering if it would see that page in that frame and try to match the caption of it.

J_K_M_A_N
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13776465
Yes Code wise the program will see the page as a seperate page. Unfortunately I am not sure if there is a way to actually directly access the a frame within a page. There might be using the documents object but I am not sure. Unfortunately I don't believe it will actually pick up the iframe in the fashion you are thinking it might.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

872 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