Subject: HELP! Can anyone solve this problem?
Posted By: JoeR Post Date: 9/1/2006 9:18:42 PM
Hi, I have googled & posted no success as yet. Can anyone help?

I have been wrestling with a problem for days. The solution is probably simple but i am not that experienced with html.
I have a vb program which  sends info to a web page and as that page fills up a button is 'pressed' and the page is submitted, cleared and reloaded again.

To login to the site the code is as follows

oIE.Document.Forms("Login").All("district").Value = "district"
oIE.Document.Forms("Login").All("password").Value = password"
oIE.Document.Forms("Login").submit

then I navigate thru several pages via code to get where I need to go
then the code I use is basically this  (with non essential info cut out)

N1 = "order.code"
N2 = "order.quantity"
While Not .EOF
    For x = 0 To 9
        If Not .EOF Then
            oIE.Document.Forms(0).All(N1 & x).Value = ![Product No]
            oIE.Document.Forms(0).All(N2 & x).Value = !Qty
        .MoveNext
        End If
        If Err = 3021 Then Exit For
    Next
     While oIE.Busy: Wend
    oIE.Document.Forms(0).submit

This works fine

So as you can see i am able to put info into forms where required. Now my problem. I have written new software that basically does the same thing but at a different site.
The login works fine but when the next page appears i am unable to enter any info into either of the 2 fields that are available

if i use the code
oIE.Document.Forms(0).All("Code").Value="1234" I get the error message
'Object variable or with block variable not set"
This is prolly because the forms(0) does not exist i think, although the form is there. I think i may need to access the document?

The html code is different for the input on this page also
On the first page the code reads
<input name="Password" type="password" id="Password" style="width:55px;" />

On the second page the code is;
<input id="SecurityCode" tabindex="1" name="SecurityCode" type="TEXT" value="" size="16" maxlength="6" />

so i do not know if there is a different way to pass a value to the "Input ID" field as opposed to the INPUT NAME field.

ANY help would be greatly appreciated as would some direction as to find out more about navigating or manipulating web pages from within VB. (events properties methods etc)

Many thanks in advance

EDIT
I have also noticed that the form name is missing and this is following the head
</head>
<link rel="stylesheet" type="text/css" HREF="/CMSIncludes/css/csall.css" title="def"/>

<body onload="document.frmSingleShare.SecurityCode.focus();">
<SCRIPT LANGUAGE="JavaScript1.2" SRC="/CMSIncludes/menu/HM_LoaderX.js" TYPE='text/javascript'></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="/CMSIncludes/menu/cfg/SHARES01.js" TYPE='text/javascript'></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="/CMSIncludes/menu/HM_LoaderXa.js" TYPE="text/javascript"></SCRIPT>

is it possible that this is a child window of sorts and that is why i cannot use the forms(0) methods
Reply By: BrianWren Reply Date: 9/4/2006 3:52:27 PM
A suggestion:  Choose subject lines that give an idea of the type of question.

One of the things I would do—just to verify—is put up a message box with the contents oIE.Document.Forms(0).name.  If that generates the same error, then you are probably right that the form doesn't exist in the context you are looking for it in.

When you say “I have also noticed that the form name is missing . . . ,” given the HTML you then present it looks more as if the form element is what is missing.  Of course, if that is so, there will be no form to reference in “oIE.Document.Forms.”

When you say “is it possible that this is a child window of sorts,” your meaning is unclear (to me).  Given the text I've made red, what does “this refer to?”  You've given no antecedent.  Do you mean “the web page that holds the running code?”  The “child window”:  maybe.  Could you expand that thought some?  (I'm thinking that your asking the question implies a suspicion you harbor, and it could be helpful to hear your thoughts on that.)
Reply By: JoeR Reply Date: 9/4/2006 10:57:41 PM
Many thx for your reply brian

Any expansion on document.forms(0). does generate an error. i have tried byelementid and that does not work either.
By "child Window" i am thinking that maybe the next window is loaded by the previous form and so loses it's focus. Sorry I cannot be more specific but i am reasonably new to this type of coding.
I have tried to access the window by the following code

Dim html as htmldocument
set html = webrowser1.document
HTML.All.item("LoginName").Value="login"
...
etc

which gives me exactly the same results. The page loads in the browser ok but i am just unable to access it via code. I can manually type the info in that i need to but that is defeating the purpose

I could send you the source of the offending page if you think u may be able to help.

Thanks again
Joe


Reply By: BrianWren Reply Date: 9/5/2006 9:56:57 AM
I think you are on the right track regarding whether there even is a form to reference.  If there is no <form . . . > </form> tag set, then you have no form to reference.

Go to topic 49316

Return to index page 184
Return to index page 183
Return to index page 182
Return to index page 181
Return to index page 180
Return to index page 179
Return to index page 178
Return to index page 177
Return to index page 176
Return to index page 175