PDA

View Full Version : [SOLVED] How to put Cursor in text box and move to next text box?



Gb.pandey
03-30-2015, 05:56 AM
Hi Guys

This is my First Post. I have some knowledge of VBA.

I need to put my cursor on a text box on web page and then move to next using tab.

Here is code of webpage:
<tr>
<td class=caption_display width = "4%"><center>3.</center></td>
<td class=caption_Mandatory width = "20%">Name of Applicant</td>
<td class=caption_data colspan =3 width = "76%"><input style="width=200;" type=textbox name=txtName maxlength=50 onfocus="return countdatavalue(ofrm.txtName.value);" onblur="return countervalues(ofrm.txtName.value);" value=></td>

</TR>
<tr>
<td class=caption_display width = "4%"><center>4.</center></td>
<td class=caption_Mandatory width = "20%">Address of Applicant </td>
<td class=caption_data colspan =3 width = "35%"><input style="width=250;" type=textbox name=txtAddress maxlength=100 onfocus="return countdatavalue(ofrm.txtAddress.value);" onblur="return countervalues(ofrm.txtAddress.value);" value=></td>

</TR>




My code is :


Private Sub CmdFillData_Click()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "*****webpage"
'wait until first page loads
Do Until .READYSTATE = 4
DoEvents
Loop
On Error Resume Next
End With
With IE.document
Application.Wait (Now + TimeValue("0:00:02"))
.forms("frmSacfa").all("txtName").setfocus
.forms("frmSacfa").all("txtName").Value = "Govind"
' SendKeys "{TAB}", True
.forms("frmSacfa").all("txtAddress").Value = "Dwarka"
End With
'Set IE = Nothing
End Sub

I need to navigate using tab to activate a button on webpage. Kindly suggest.

Gb.pandey
04-07-2015, 11:47 PM
Guys help.

mancubus
04-07-2015, 11:58 PM
welcome to vbax.

these may help:

http://answers.microsoft.com/en-us/office/forum/office_2007-customize/using-vba-to-enter-data-into-an-html-form/41eb57b0-244b-4f61-80be-fb17033813d6

http://www.jpsoftwaretech.com/an-exploration-of-ie-browser-methods-part-i/
http://www.jpsoftwaretech.com/an-exploration-of-ie-browser-methods-part-ii/