Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebBrowser usage problem... 1

Status
Not open for further replies.

KyleS

Programmer
Oct 23, 2001
619
US
Hi,

I've looked throughout the archives and I can't find a solution to my only problem (so far) with the WebBrowser.

I have a form (which I don't own) that I need to push a button on. I know the syntax is:

WB.Document.All("ButtonName").Click

But the problem is, there is no name for the button.

Here's the HTML for the button:

<TD VALIGN='top'>
<INPUT type='button' OnClick='IN_CHECK()' value='Start' style=&quot;FONT-SIZE: 24px; HEIGHT: 40px; WIDTH: 120px&quot;>
</TD>


I've tried WB.Document.All(&quot;Start&quot;) and that's a no go. I took all the source and entered it into Front page and used the preview there to give me all the available details on the button (In case I missed something) but there really is no name on any of the buttons on ths form (there are 4)

So the only solution I can think of is to grab the collection of buttons and look at the &quot;Value&quot; and find the button I want. But since there is a supreme lack of literature on the use of this I can't seem to find how to reference that collection.

I've used this to get ahold of the tags (hyperlinks) so I'm thinking this will work if I can just get it to look at the buttons.

Dim objElements As Object, i As Integer
Dim objElement As Object
Dim objToClick As Object
Set objToClick = Nothing
Set objElements = WB.Document.All.tags(&quot;Value&quot;)
For Each objElement In objElements
If LCase(objElement.innerText) Like &quot;*start*&quot; Then
''if LCase(objElement.outerHtml) Like &quot;*somehtml*&quot; then
Set objToClick = objElement
Exit For
End If
Next
If Not objToClick Is Nothing Then objToClick.Click


Any and all sugestions are appreciated.

Kyle
 
Kyle,

If it's not a problem, can you give us the URL of the site?
If it is, for whatever reason, can you give the URL of a similiar site. There are just a lot of unknowns, that make it hard to answer the question, without looking at the source.

Steve
 
Hi Steve,

Thnks for the response. Unfortuntely I can't give you the website because it on out intranet at work. I'm still looking for an example, the best one I can find is in my Yahoo! mail page, as the buttons there have similar properties...

I'll try and get a better example, as the &quot;nameless&quot; buttons are only on the page that is viewed AFTER you log into the e-mail.



Kyle
 
Hi again,

Well, I'm a t a loss for similar pages, but I'll post the HTML of the page (minus all the VB script) and maybe this will help? I just can't find any good reference to the syntax on this darned thing. All I need to grab is the collection of &quot;buttons&quot; and from there I can get it, no problem... Any suggestions anyone? I'm already using my WebBrowser control to enter text into the fields I need... Just need that darned button...

Thanks in advance...

Code:
<!--	**********	t	********** -->  
   
<FORM action='Page1.ASP' name='form1' method='post'>     
<INPUT type='hidden' name='sysname' value='Post1­'>     
<INPUT type='hidden' name='car_unit' value='QQ'>     
<INPUT type='hidden' name='pgm_id' value='Page4'>     
<INPUT type='hidden' name='logon_user' value='User-Name'>     
     
<!--	**********	‚	********** -->     
<TABLE border='0' width='700'>     
<TR>     
	<TD width='40' nowrap> </TD>     
	<TD class='KAIHATUCOLOR' nowrap>     
		<H2><B><U><I>     
		<INPUT type='radio' name='system' OnClick='RADSEL1( &quot;Post1­&quot; )' checked>     
		Development     
		</I></U></B></H2>     
 
		           
		<INPUT type='radio' name='carunit' OnClick='RADSEL2( &quot;QQ&quot; )' checked>     
		Project (Vehicle)     
		              
		Project code /Unit code :      
		<INPUT type='text' name='project' maxlength='10' size='13' value=''>     
		<BR>     
		           
		<INPUT type='radio' name='carunit' OnClick='RADSEL2( &quot;U&quot; )'>     
		Unit Project      
		<BR>     
	</TD>     
	<TD> </TD>     
	<TD> </TD>     
	<TD VALIGN='top'>     
	<INPUT type='button' OnClick='IN_CHECK()' value='Start' style=&quot;FONT-SIZE: 24px; HEIGHT: 40px; WIDTH: 120px&quot;>      
	</TD>     
</TR>     
<!--	**********   2000/6/1	********** -->     
<TR>     
	<TD width='40'> </TD>     
	<TD class='SHINCHOKUCOLOR' nowrap>     
		<H2><B><U><I>     
		<INPUT type='radio' name='system' OnClick='RADSEL1( &quot;Post1-Post5&quot;)' >     
		Progress Report    
		</I></U></B></H2>     
	</TD>     
	<TD> </TD>     
	<TD> </TD> 
<!--	**********	ƒ}	********** -->
	<TD VALIGN='top'>
	<INPUT type='button' OnClick='MANUAL()' value='Manual' style=&quot;FONT-SIZE: 24px; HEIGHT: 40px; WIDTH: 120px&quot;>
	</TD>     
</TR>     
     
     
<!--	**********	}	********** -->     
<TR>     
	<TD width='40'> </TD>     
	<TD class='MASTERCOLOR' nowrap>     
		<H2><B><U><I>     
		<INPUT type='radio' name='system' OnClick='RADSEL1( &quot;ƒ}ƒXƒ^ƒƒ“ƒeƒiƒ“ƒX&quot; )' >     
		Master Maintenance     
		</I></U></B></H2>     
		           
		Password : <INPUT type='password' name='pword' size='13' maxlength='10' value=''>     
		<BR>     
	</TD>     
	<TD> </TD>     
	<TD> </TD> 
<!--	**********	2001/03/14	2003/05/15	  2000/6/26	********** -->
	<TD>
	<INPUT type='button' OnClick='SIRYOU()' value='Concept' style=&quot;FONT-SIZE: 24px; HEIGHT: 40px; WIDTH: 120px&quot;> 
	</TD>     
</TR>     

<TR>
        <TD></TD><TD></TD><TD></TD><TD></TD>
<!--	**********	2000/05/15		********** -->
	<TD>
	 <BR>
	<INPUT type='button' OnClick='SAMPLE()' value='JE_Sample' style=&quot;FONT-SIZE: 24px; HEIGHT: 40px; WIDTH: 120px&quot;>
	</TD>
</TR>
  
</TABLE>     
</FORM>

Kyle
 
Using your existing code, here's an example using the button that with the value &quot;Concept&quot;. Since the name of the form is known (form1), you can use that to only look for elements of the form form1

Code:
Dim objElements As Object, i As Integer
Dim objElement As Object
Dim objToClick As Object
Set objToClick = Nothing
Set objElements = WB.Document.form1.elements
For Each objElement In objElements
   If objElement.Type = &quot;button&quot; Then
       If LCase(objElement.Value) = &quot;concept&quot; Then
          objToClick = objElement
       End If
   End If
Next
If Not objToClick Is Nothing Then objToClick.Click

Steve
 
Steve,

Thank you so much. This is exactly what I need (especially since there are 3 other forms without button names).

Just as an FYI, here's the code I'm using:

Dim objElements As Object
Dim objElement As Object

Set objElements = WB.Document.form1.elements
For Each objElement In objElements
If objElement.Type = &quot;button&quot; Then
If LCase(objElement.Value) = &quot;concept&quot; Then
objElement.Click
Exit For
End If
End If
Next


I kept getting an &quot;Object not defined&quot; error on the line &quot;objToClick = objElement&quot;, so I just adjusted as I needed.

Thank again,

Kyle
 
Kyle,

I don't know what I was thinking, it should have been:

Code:
...
set objToClick = objElement
...

By the way, the elements collection deosn't include input type=image objects.

Steve
 
Well, I should have seen that myself... Thanks Steve..

Now, which collection does contain the images...?

Thanks again,

Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top