Results 1 to 21 of 21

Thread: VB6 InternetExplorer Object (Resolved)

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Resolved VB6 InternetExplorer Object (Resolved)

    Hers the problem .

    From VB6 (not .Net) I find an active IE window that is on the required site that I am interested in by reading the current URL line for each tab.

    I then read the html from that screen to confirm that it is on the correct screen if not send to the address box to move to the required html page.

    On that page are lots of tables each having a name within the page html code.

    All that works fine for routing and reading.

    What I need to do is place my required data in those named text boxes and then post or submit the page but I cant find the required syntax for the InternetExplored object to do this can anyone help please.
    Last edited by ArferMo; Sep 25th, 2008 at 04:56 PM.

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please

    Does anyone know how to send text to specific table cells from VB6 to an active InternetExplorer window and then submit the page.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please

    Got a bit further, now managed to send some data to the tables and submit them but I have come to another table that is causing me some trouble....

    Here is the code from the table segment where I have problems:-

    <form ACTION="my_form.cfm" METHOD="POST" onsubmit="return Form2_Validator(this)" name="Form2">
    <p align="center">
    <center>


    <table border="0" width="70%" bgcolor="BFE6FD" cellspacing="0" cellpadding="3">

    <tr>
    <td width="46%" align="right"><b><font size="2" face="Tahoma">Duration:</font></b></td>
    <td width="54%"><b><font face="Tahoma" size="2"><select size="1" name="Hours">
    <option value="00" selected>00</option>
    <option value="01">01</option>
    <option value="02">02</option>
    <option value="03">03</option>
    <option value="04">04</option>
    <option>05</option>
    <option>06</option>
    <option>07</option>
    <option>08</option>
    <option>09</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
    <option>13</option>
    <option>14</option>
    <option>15</option>
    </select> </font> </b>
    </td>
    </tr>
    <tr>
    <td width="46%" align="right"><b><font size="2" face="Tahoma">Cost type:</font></b></td>
    <td width="54%"><select size="1" name="Type">
    <option selected value="Please Select">Please Select</option>
    <option>BTC</option>
    <option>TRAV</option>
    <option>CPO</option>
    <option>EM</option>
    </select></td>
    </tr>

    Here is my code:-

    Set objIE = New InternetExplorer
    objIE.Visible = True

    objIE.document.All("Hours").Value = "03"
    objIE.document.All("Type").Value.Select = "CPO"

    This line works fine objIE.document.All("Hours").Value = "03" and 03 is visible in the correct area on the browser window.

    But the next line objIE.document.All("Type").Value = "CPO" causes the cell to from the default load value of Please Select to blank.

    Could someone please tell me the correct syntax to set this cell to CPO.

  4. #4
    Member
    Join Date
    Mar 2008
    Posts
    55

    Re: VB6 InternetExplorer Object HELP Please

    i think this will work.
    Code:
    objIE.document.All("Type").Value = "CPO"

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please

    Thanks for the suggestion. I have givven it a try and it still sets that cell to blank.

    Anyone got any other suggestions PLEASE

  6. #6
    Member
    Join Date
    Mar 2008
    Posts
    55

    Re: VB6 InternetExplorer Object HELP Please

    whats the website and is the box a dropdown menue ??
    Code:
    WebBrowser1.Document.All("Type"").Value = "CPO"

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please

    It's an intranet site I'm afraid.

    Yes it is a drop down box but then so is the cell that I set on the line before and that works fine.

    There are several other cells on the web page that I set successfully all except this one. But then if you look at the html code that cell is written in a slightly different way, but I can't change that.

  8. #8
    Member
    Join Date
    Mar 2008
    Posts
    55

    Re: VB6 InternetExplorer Object HELP Please

    attach the html and i will have a look at it.

    Quote Originally Posted by ArferMo
    It's an intranet site I'm afraid.

    Yes it is a drop down box but then so is the cell that I set on the line before and that works fine.

    There are several other cells on the web page that I set successfully all except this one. But then if you look at the html code that cell is written in a slightly different way, but I can't change that.

  9. #9

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please

    OK I have loaded the form to a publicly accessible area, remember this is not my form so I can't change the working one, I have to use it as is once I can figure out how to get "CPO" into the required Work Type: cell with your help.

    Here is my code so far:-

    Private Sub Command1_Click()
    Set objIE = New InternetExplorer
    objIE.Visible = True

    objIE.Navigate2 "http://arthurbard.com/MyTestArea/OT_New.htm"

    DoEvents
    Do While objIE.Busy
    DoEvents
    Loop

    While objIE.readyState <> 4
    DoEvents
    Wend

    DoEvents

    objIE.document.All("Hours").Value = "03"
    objIE.document.All("Type").Value = "CPO"
    objIE.document.All("Job_no").Value = "Testing"
    objIE.document.All("Remarks").Value = "This is a test record please ignore."
    MsgBox "Now why is the work type cell blank and not showing CPO."
    End Sub

  10. #10
    Member
    Join Date
    Mar 2008
    Posts
    55

    Re: VB6 InternetExplorer Object HELP Please

    please attach the html page.

  11. #11

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please

    You could get it from the on line pager in the code above.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    
    <br>
    
    <form ACTION="pin_res.cfm" METHOD="POST" onsubmit="return Form2_Validator(this)" name="Form2"> 
    <p align="center"> 
    <center> 
    
    <table border="0" width="70%" bgcolor="BFE6FD" cellspacing="0" cellpadding="3">
      
      <tr>
        <td width="46%" align="right"><b><font face="Tahoma" size="2">First Name:</font></b></td>
        <td width="54%"><b><font face="Tahoma" size="2">Richard</font></b></td>
      </tr>
      <tr>
        <td width="46%" align="right"><b><font face="Tahoma" size="2">Surname:</font></b></td>
        <td width="54%"><b><font face="Tahoma" size="2">Woodbine</font></b></td>
      </tr>
      <tr>
        <td width="46%" align="right"><b><font face="Tahoma" size="2">Shop:</font></b></td>
        <td width="54%"><b><font face="Tahoma" size="2">ASDA</font></b></td>
      </tr>
      <tr>
        <td width="46%" align="right"><b><font face="Tahoma" size="2">Grade:</font></b></td>
        <td width="54%"><b><font face="Tahoma" size="2">Checkout Op</font></b></td>
      </tr>
      <tr>
        <td width="46%" align="right"><b><font size="2" face="Tahoma">Entered by:</font></b></td>
        <td width="54%"><b><font face="Tahoma" size="2">287881480</font></b></td>
      </tr>
      <tr>
        <td width="46%" align="right"><b><font size="2" face="Tahoma">Work Duration:</font></b></td>
        <td width="54%"><b><font face="Tahoma" size="2"><select size="1" name="Hours">
            <option value="00" selected>00</option>
            <option value="01">01</option>
            <option value="02">02</option>
            <option value="03">03</option>
            <option value="04">04</option>
            <option>05</option>
            <option>06</option>
            <option>07</option>
            <option>08</option>
            <option>09</option>
            <option>10</option>
            <option>11</option>
            <option>12</option>
    		<option>13</option>
    		<option>14</option>
    		<option>15</option>
          </select>  </font> </b>
    	  
    	  <font face="Tahoma" size="2"><b>Hrs </b> <select size="1" name="Minutes">
            <option selected>00</option>
            <option>15</option>
            <option>30</option>
            <option>45</option>
          </select> <b> Mins&nbsp;</b>        
    	  <input type="text" name="Estimate" size="2" maxlength="1" value="Y">
          <b>Estimate(Y/N)</b></font></td>
      </tr>
      <tr>
        <td width="46%" align="right"><b><font size="2" face="Tahoma">Work Type:</font></b></td>
        <td width="54%"><select size="1" name="Type">
            <option selected value="Please Select">Please Select</option>
            <option>STD</option>
            <option>TRAV</option>
            <option>CPO</option>
            <option>EM</option>
          </select></td>
      </tr>
      
     <tr>
        <td width="46%" align="right"><b><font size="2" face="Tahoma">Work Date:</font></b></td>
    	<td width="46%" >
    		<select name=day>
    		<option selected value=22   >  22  </option>
    		<option >01</option><option >02</option><option >03</option>
    		<option >04</option><option >05</option><option >06</option>
    		<option >07</option><option >08</option><option >09</option>
    		<option >10</option><option >11</option><option >12</option>
    		<option >13</option><option >14</option><option >15</option>
    		<option >16</option><option >17</option><option >18</option>
    		<option >19</option><option >20</option><option >21</option>
    		<option >22</option><option >23</option><option >24</option>
    		<option >25</option><option >26</option><option >27</option>
    		<option >28</option><option >29</option><option >30</option>
    		<option >31</option>
    	</select>
    
    	<select name=month >
    		<option selected  value=09    > September </option>
    		<option value="01">January</option>
    		<option value="02">February</option>
    		<option value="03">March</option>
    		<option value="04">April</option>
    		<option value="05">May</option>
    		<option value="06">June</option>
    		<option value="07">July</option>
    		<option value="08">August</option>
    		<option value="09">September</option>
    		<option value="10">October</option>
    		<option value="11">November</option>
    		<option value="12">December</option>
    	</select>
    	
    	<select name="year">	
    		<option selected value=2008>  2008 </option>
    		<option >2007</option>
    		<option >2009</option>
    	</select>
    	</td>
    	</tr>  
      <tr>
        <td width="46%" align="right"><b><font size="2" face="Tahoma">Job Ref. </font></b></td>
        <td width="54%"><b><font face="Tahoma" size="2">
    	<input type="text" name="Job_no" size="10" maxlength="10"></font></b></td>
      </tr>
      <tr>
        <td width="46%" align="right"><b><font face="Tahoma" size="2">Remarks:</font></b></td>
        <td width="54%"><textarea rows="4" name="Remarks" wrap="virtual" cols="30"></textarea></td>
      </tr>
    </table>
    
    <br>
    <input TYPE="SUBMIT" VALUE="Update work log for Richard&nbsp;Woodbine&nbsp;ASDA">
    
    <input type="hidden" name="forename" value="Richard">
    <input type="hidden" name="surname" value="Woodbine">
    <input type="hidden" name="shop" value="ASDA">
    <input type="hidden" name="grade" value="Checkout Op">
    <input type="hidden" name="employe" value="287881480">
    
    </form>
    
    <br><br>
    
    </center>
    	</td>
    	</tr>
    	<tr>
    	<td align="right" valign="bottom" width="100%"></td>
    	</tr>
    
    </table>
    
    </body>
    </html>
    Last edited by si_the_geek; Sep 23rd, 2008 at 06:24 AM. Reason: added code tags

  12. #12

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    This is a most perplexing problem. Is no one able to offer a coding solution?

  13. #13

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    I know that the problem is caused by an html coding problem on the page but I am unable to get that corrected.

    But if you can manually click on the drop down arrow in the "Work Type" box to drop the menu down then click on the "CPO" option.... then why can't you do it withing the VB6 code.

    FAULTY LINE
    <option>CPO</option>


    CORRECTED LINE
    <option value ="CPO">CPO</option>

    But how to do it in VB6 on the page with the html error.

  14. #14
    Member
    Join Date
    Mar 2008
    Posts
    55

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    due to the coding glitch, i think it would be hard to do, i am not sure of a way to do it.

    if if i was you, i would make it so 99% is auto e.g up to this point then after this point its manual.

  15. #15

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    Is it possible to set the value by some sort of index or option value to set it to CPO

    Problem with VB is that as you type the line:-
    objIE.document.All("Type").Value = "CPO"

    After you get to objIE.document you get no syntax help so I am rather in the dark after that.

    <tr>
    <td width="46%" align="right"><b><font size="2" face="Tahoma">Work Type:</font></b></td>
    <td width="54%"><select size="1" name="Type">
    <option selected value="Please Select">Please Select</option>
    <option>STD</option>
    <option>TRAV</option>
    <option>CPO</option>
    <option>EM</option>
    </select></td>
    </tr>

  16. #16
    Member
    Join Date
    Mar 2008
    Posts
    55

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    dont think this will work but you could try:

    CPO (4)

    Code:
    objIE.document.All("Type").index = "4"
    Last edited by Delboy23; Sep 24th, 2008 at 12:13 PM.

  17. #17

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    You are correct it doesn't work.

    Error 438
    Object does not support this property or method.

  18. #18
    Member
    Join Date
    Mar 2008
    Posts
    55

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    as i expected but worth a try i suppose.

    you could try something like option 4, but again i am not sure this will work. like i said before i would suggest having most auto but a little manual.

    Quote Originally Posted by ArferMo
    You are correct it doesn't work.

    Error 438
    Object does not support this property or method.

  19. #19
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    this works
    Code:
    Const CPO = 3
    objie.document.All("Type").selectedindex = CPO
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  20. #20

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    15

    Re: VB6 InternetExplorer Object HELP Please. Are you all beat ?

    That's great westconn1 THANK YOU. I have been struggling for a week and a half to crack this problem.

    Is there any documentation for commands for this object for things like selectedindex I did not know that that was an acceptable command.

  21. #21
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VB6 InternetExplorer Object (Resolved)

    i had never used an explorer object, so i had search, around for a while, in the element properties, to find what property could be set for that element, i have no idea if there is any documentation, i guess there is somewhere
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width