larryjfoster
New Member
- Joined
- Jul 19, 2017
- Messages
- 20
Hello!
the below code will successfully navigate to an intranet site, input a value into a form field, press submit button and follow a hyperlink. Where I'm getting stuck is to select a value from a drop down list (which is inserted in a table - not sure if that matters).
From the source code of the intranet site
the below code will successfully navigate to an intranet site, input a value into a form field, press submit button and follow a hyperlink. Where I'm getting stuck is to select a value from a drop down list (which is inserted in a table - not sure if that matters).
Code:
Dim URL As String
Dim IE As InternetExplorerMedium
Dim i As Long
Dim wsSrc As Worksheet
Dim lr As Long
Dim dtDate As String
Dim Auth As String
Dim runDate As Date
'Create InternetExplorer Object
Set IE = New InternetExplorerMedium
'Set IE.Visible = True to make IE visible, or False for IE to run in the background
IE.Visible = True
'Define URL
URL = "myintranet.aspx"
'Navigate to URL
IE.Navigate URL
'Wait while IE loading...
Do While IE.Busy Or Not IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Get Window ID for IE so we can set it as activate window
HWNDSrc = IE.HWND
'Set IE as Active Window
SetForegroundWindow HWNDSrc
Set wsSrc = Application.ActiveWorkbook.Sheets(1)
lr = wsSrc.UsedRange.Rows.Count
runDate = wsSrc.Range("AH2")
With wsSrc
For i = 2 To lr
Auth = Cells(i, 3)
'input auth number in IE
IE.Document.all("MemSearch:_ctl0:txtAuthId").Value = Auth
'press search button
IE.Document.all("MemSearch:_ctl0:btnAuthSearch").Click
'Wait while IE loading...
Do While IE.Busy Or Not IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Navigate to Care Activities form by clicking Care Activities hyperlink
IE.Navigate "javascript:__doPostBack('Navigation','Evnt:Redirect:CareActivities.aspx')"
'Wait while IE loading...
Do While IE.Busy Or Not IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Change Activity Date to Run Date
IE.Document.all("ucCareActivityDetail:dtActivityDate:txt_dtActivityDate").Value = Format(runDate, "mm/dd/yyyy")
[COLOR=#FF0000] 'Select from Activity type dropdown "Mail - Outbound"
IE.Document.all("ucCareActivityDetail:cboActivityType:cboActivityType*d1").Value = "Mail - Outbound"
[/COLOR]
From the source code of the intranet site
Code:
<span id="ucCareActivityDetail_lblActivityType" style="width:100%;">Activity Type: *</span></TD>
<TD width="25%">
<span id="ucCareActivityDetail_cboActivityType" style="display:inline-block;"><span id="ucCareActivityDetail_cboActivityType_cboActivityType*L1" style="width:0%;"></span><select name="ucCareActivityDetail:cboActivityType:cboActivityType*d1" onchange="(currentElement = 'DonotUnlockEnrollee******');DropDownChanged('ucCareActivityDetail_cboActivityType_cboActivityType*d1','ucCareActivityDetail_cboActivityType_cboActivityType*hDropDownValue');ActivityTypeChanged('ucCareActivityDetail_txtComments','ucCareActivityDetail_cboActivityType_cboActivityType*d1','ucCareActivityDetail_HdnActivityTypeWithComment','ucCareActivityDetail_HdnActivityTypeOverWriteFlag');setTimeout('__doPostBack(\'ucCareActivityDetail$cboActivityType$cboActivityType*d1\',\'\')', 0)" language="javascript" id="ucCareActivityDetail_cboActivityType_cboActivityType*d1" Alt="Activity Type" AddEmptyRow="false" style="font-weight:normal;width:100%;">
<option selected="selected" value=""></option>
<option value="119">7/30 Day Follow-Up</option>
<option value="244">ABA Auth Complete</option>
<option value="99">Mail Outbound</option>
</select><input name="ucCareActivityDetail:cboActivityType:cboActivityType*hDropDownValue" type="hidden" id="ucCareActivityDetail_cboActivityType_cboActivityType*hDropDownValue" /><span controltovalidate="ucCareActivityDetail_cboActivityType_cboActivityType*d1" id="ucCareActivityDetail_cboActivityType__ctl0" evaluationfunction="TextValidatorIsValid" style="color:Red;visibility:hidden;"></span></span></TD>
<input name="ucCareActivityDetail:HdnActivityType" type="hidden" id="ucCareActivityDetail_HdnActivityType" size="0" /></TD>
<input name="ucCareActivityDetail:HdnActivityTypeOverWriteFlag" type="hidden" id="ucCareActivityDetail_HdnActivityTypeOverWriteFlag" size="0" /></TD>
<input name="ucCareActivityDetail:HdnActivityTypeWithComment" type="hidden" id="ucCareActivityDetail_HdnActivityTypeWithComment" size="0" value="179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|217|218|219|220|221|222|223|224|225|226|227|228|229|215|216|237|238|239|240|241|245|246|247|248|249|250|251|252|253|254|255|256|257|258|" /></TD>
</TR>