Entering data into input cells on a website

stilesbn

Board Regular
Joined
Feb 21, 2011
Messages
66
I have some code where VBA logs into a website and enters in some information from an excel sheet into a table on the website.

This works well with the first couple of cells in the table because they are normal input cells like this.

HTML:
 <tr>
                        <td align="right">
                            USS Order ID:
                        </td>
                        <td align="left">
                            <input name="ctl00$MainContent$ImportWizard$wzImportRecords$txtUSSOrderID" type="text" id="ctl00_MainContent_ImportWizard_wzImportRecords_txtUSSOrderID" tabindex="1" /><font color="red">*</font>
                        </td>

My VBA code works great for this.

Code:
Sub SiteInput()

Dim lSheet As Worksheet
Dim lBook As Workbook
Dim counter As Integer
Dim keepGoing As Boolean
Dim lastRow As Integer
Dim i As Long


Set lSheet = ActiveSheet
Set lBook = ActiveWorkbook

With lSheet
    lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

counter = ActiveCell.Row

Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .navigate "http://utahnet.dialogue-marketing.com/UrbanSettlementCRM/RecordImport/RecordImport.aspx"
        Do Until .ReadyState = 4
            DoEvents
        Loop
        
        
        .document.forms(0).elements("ctl00$MainContent$ImportWizard$wzImportRecords$ddlProgram").Value = "20"
        .document.all.Item("ctl00$MainContent$ImportWizard$wzImportRecords$txtUSSOrderID").Value _
            = lSheet.Cells(counter, 1).Value
        .document.all.Item("ctl00$MainContent$ImportWizard$wzImportRecords$txtSubGroup").Value _
            = lSheet.Cells(counter, 2).Value
        .document.all.Item("ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_text").Value _
            = lSheet.Cells(counter, 3).Value
        .document.all.Item("ctl00_MainContent_ImportWizard_wzImportRecords_rdpStartDate_dateInput_text").Value _
            = lSheet.Cells(counter, 4).Value
        .document.all.Item("ctl00_MainContent_ImportWizard_wzImportRecords_rdpSLADate_dateInput_text").Value _
            = lSheet.Cells(counter, 5).Value
        .document.all.Item("ctl00_MainContent_ImportWizard_wzImportRecords_rdpEndDate_dateInput_text").Value _
            = lSheet.Cells(counter, 6).Value
        .document.all.Item("ctl00_MainContent_ImportWizard_wzImportRecords_rdpEndDate_dateInput_text").Click

        
        Call .document.parentWindow.execScript("__doPostBack()", "JavaScript")
            .document.forms("aspnetForm").submit

However, four of the input cells are date input cells where you can either type in the date or click on the little calendar button and select the date. The code above will enter a date into the cell but it's not registering. The date will appear there but if I submit the page they will disappear and I'll get a message saying I did not enter the date. Also if you try to click on the date to modify it it will disappear.

HTML:
<tr>
                        <td align="right">
                            Receipt Date:
                        </td>
                        <td align="left">
                            <div id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_wrapper" class="RadPicker RadPicker_Default " style="display:inline-block;width:150px;">
				<input style="visibility:hidden;display:block;float:right;margin:0 0 -1px -1px;width:1px;height:1px;overflow:hidden;border:0;padding:0;" id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate" name="ctl00$MainContent$ImportWizard$wzImportRecords$rdpReceiptDate" type="text" class="rdfd_" value="" /><table cellspacing="0" class="rcTable" style="width:100%;">
					<tr>
						<td class="rcInputCell" style="width:100%;"><span id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_wrapper" class="RadInput RadInput_Default" style="display:block;"><input type="text" id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_text" name="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_text" class="riTextBox riEnabled" tabindex="3" style="width:100%;" /><input style="visibility:hidden;float:right;margin:-18px 0 0 -1px;width:1px;height:1px;overflow:hidden;border:0;padding:0;" id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput" name="ctl00$MainContent$ImportWizard$wzImportRecords$rdpReceiptDate$dateInput" type="text" class="rdfd_" value="" /><input id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_ClientState" name="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_ClientState" type="hidden" /></span></td><td><a title="Open the calendar popup." href="#" id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_popupButton" class="rcCalPopup">Open the calendar popup.</a><div id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_wrapper" style="display: none" ><table id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar" summary="Calendar" cellspacing="0" class="RadCalendar RadCalendar_Default" border="0">
							<thead>
								<tr>
									<td class="rcTitlebar"><table cellspacing="0" summary="title and navigation" border="0">
										<tr>
											<td><a id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_FNP" class="rcFastPrev" title="<<" href="#"><<</a></td><td><a id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_NP" class="rcPrev" title="<" href="#"><</a></td><td id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Title" class="rcTitle">July 2011</td><td><a id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_NN" class="rcNext" title=">" href="#">></a></td><td><a id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_FNN" class="rcFastNext" title=">>" href="#">>></a></td>
										</tr>
									</table></td>
								</tr>
							</thead><tbody>
	<tr>
		<td class="rcMain"><table id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top" class="rcMainTable" cellspacing="0" summary="July 2011" border="0">
	<thead>
		<tr class="rcWeek">
			<th class="rcViewSel"> </th><th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_cs_1" title="Sunday" abbr="Sun" scope="col">S</th><th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_cs_2" title="Monday" abbr="Mon" scope="col">M</th><th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_cs_3" title="Tuesday" abbr="Tue" scope="col">T</th><th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_cs_4" title="Wednesday" abbr="Wed" scope="col">W</th><th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_cs_5" title="Thursday" abbr="Thu" scope="col">T</th><th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_cs_6" title="Friday" abbr="Fri" scope="col">F</th><th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_cs_7" title="Saturday" abbr="Sat" scope="col">S</th>
		</tr>
	</thead><tbody>
		<tr class="rcRow">
			<th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_rs_1" scope="row">27</th><td class="rcOtherMonth" title="Sunday, June 26, 2011"><a href="#">26</a></td><td class="rcOtherMonth" title="Monday, June 27, 2011"><a href="#">27</a></td><td class="rcOtherMonth" title="Tuesday, June 28, 2011"><a href="#">28</a></td><td class="rcOtherMonth" title="Wednesday, June 29, 2011"><a href="#">29</a></td><td class="rcOtherMonth" title="Thursday, June 30, 2011"><a href="#">30</a></td><td title="Friday, July 01, 2011"><a href="#">1</a></td><td class="rcWeekend" title="Saturday, July 02, 2011"><a href="#">2</a></td>
		</tr><tr class="rcRow">
			<th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_rs_2" scope="row">28</th><td class="rcWeekend" title="Sunday, July 03, 2011"><a href="#">3</a></td><td title="Monday, July 04, 2011"><a href="#">4</a></td><td title="Tuesday, July 05, 2011"><a href="#">5</a></td><td title="Wednesday, July 06, 2011"><a href="#">6</a></td><td title="Thursday, July 07, 2011"><a href="#">7</a></td><td title="Friday, July 08, 2011"><a href="#">8</a></td><td class="rcWeekend" title="Saturday, July 09, 2011"><a href="#">9</a></td>
		</tr><tr class="rcRow">
			<th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_rs_3" scope="row">29</th><td class="rcWeekend" title="Sunday, July 10, 2011"><a href="#">10</a></td><td title="Monday, July 11, 2011"><a href="#">11</a></td><td title="Tuesday, July 12, 2011"><a href="#">12</a></td><td title="Wednesday, July 13, 2011"><a href="#">13</a></td><td title="Thursday, July 14, 2011"><a href="#">14</a></td><td title="Friday, July 15, 2011"><a href="#">15</a></td><td class="rcWeekend" title="Saturday, July 16, 2011"><a href="#">16</a></td>
		</tr><tr class="rcRow">
			<th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_rs_4" scope="row">30</th><td class="rcWeekend" title="Sunday, July 17, 2011"><a href="#">17</a></td><td title="Monday, July 18, 2011"><a href="#">18</a></td><td title="Tuesday, July 19, 2011"><a href="#">19</a></td><td title="Wednesday, July 20, 2011"><a href="#">20</a></td><td title="Thursday, July 21, 2011"><a href="#">21</a></td><td title="Friday, July 22, 2011"><a href="#">22</a></td><td class="rcWeekend" title="Saturday, July 23, 2011"><a href="#">23</a></td>
		</tr><tr class="rcRow">
			<th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_rs_5" scope="row">31</th><td class="rcWeekend" title="Sunday, July 24, 2011"><a href="#">24</a></td><td title="Monday, July 25, 2011"><a href="#">25</a></td><td title="Tuesday, July 26, 2011"><a href="#">26</a></td><td title="Wednesday, July 27, 2011"><a href="#">27</a></td><td title="Thursday, July 28, 2011"><a href="#">28</a></td><td title="Friday, July 29, 2011"><a href="#">29</a></td><td class="rcWeekend" title="Saturday, July 30, 2011"><a href="#">30</a></td>
		</tr><tr class="rcRow">
			<th id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_Top_rs_6" scope="row">32</th><td class="rcWeekend" title="Sunday, July 31, 2011"><a href="#">31</a></td><td class="rcOtherMonth" title="Monday, August 01, 2011"><a href="#">1</a></td><td class="rcOtherMonth" title="Tuesday, August 02, 2011"><a href="#">2</a></td><td class="rcOtherMonth" title="Wednesday, August 03, 2011"><a href="#">3</a></td><td class="rcOtherMonth" title="Thursday, August 04, 2011"><a href="#">4</a></td><td class="rcOtherMonth" title="Friday, August 05, 2011"><a href="#">5</a></td><td class="rcOtherMonth" title="Saturday, August 06, 2011"><a href="#">6</a></td>
		</tr>
	</tbody>
</table></td>
	</tr>
</tbody>
						</table><input type="hidden" name="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_SD" id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_SD" value="[]" /><input type="hidden" name="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_AD" id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_calendar_AD" value="[[1980,1,1],[2099,12,30],[2011,7,6]]" /></div></td>
					</tr>
				</table><input id="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_ClientState" name="ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_ClientState" type="hidden" />
			</div>
                            <font color="red">*</font>
                        </td>

I've tried pointing the date to be input into the hidden inputs in the begining of the code pointing it at "ctl00$MainContent$ImportWizard$wzImportRecords$rdpReceiptDate" or "ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_ClientState".

Neither of these worked. Does anyone have any idea what kind of code is needed to get the date to successfully enter?
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Use the Format function to format the date string value to whatever format is required by the input field, for example:
Code:
            .document.all.Item("ctl00_MainContent_ImportWizard_wzImportRecords_rdpReceiptDate_dateInput_text").Value _
            = Format(lSheet.Cells(counter, 3).Value, "dd-mm-yyyy")
 
Upvote 0
Why are you calling the do_PostBack script?

What happens if you don't and just submit the form?

Also when you enter a date manually is any code being triggered?

If it is you would probably notice a slight delay while things are updated.

The sort of code I'm thinking of is where you select/enter something and the rest of the input fields are updated

eg cascading comboboxes where the value selected in a 'parent' combobox determine the values in a 'child' combobox.
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,691
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top