Unable to FIll out Search Input box in the website using VBA

jmarvin_18

New Member
Joined
Jun 27, 2017
Messages
6
Hi,

I'm trying to integrate our Excel Tool to our customer information database to quickly search for information. I was able to control some of the hyperlinks and button I just want to ask some help on how I can auto fill the the input Search Box in the website that we're using in our office.

Sub crm()

'On Error Resume Next

Dim MyHTML_Element As IHTMLElement
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInputs As MSHTML.IHTMLElementCollection
Dim HTMLInput As IHTMLElement
Dim elements As MSHTML.IHTMLElementCollection

IE.navigate "10.163.74.252/ProView/main.aspx#"
IE.Visible = True


Do
DoEvents
Loop Until IE.readyState = 4

Set HTMLDoc = IE.document

Set Allhyperlinks = IE.document.getElementsByTagName("nobr")
For Each hyper_link In Allhyperlinks
If hyper_link.innerText = "Provider" Then
hyper_link.Click
Exit For
End If
Next

Do
DoEvents
Loop Until IE.readyState = 4

Set aAllhyperlinks = IE.document.getElementsByTagName("A")
For Each hyper_link In aAllhyperlinks
If hyper_link.innerText = "Contacts" Then
hyper_link.Click
Exit For
End If
Next


Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop

Set HTMLInput = HTMLDoc.getElementById("crmGrid_findCriteria")
HTMLInput.Value = "12546892"



End Sub


HTML Code
________________________________________________________________________________________________

<table width="100%" title="Use asterisk (*) wildcard character to search on partial text" cellspacing="0" cellpadding="0"><tbody>
<tr id="crmGrid_quickFindContainer" gridid="crmGrid">
<td valign="top" style="width: 100%; overflow: hidden;"><div style="position: relative;">
<label class="ms-crm-Dialog-Lookup-QuickFindHint ms-crm-TextAutoEllipsis" id="crmGrid_findHintText" style="display: inline;" for="crmGrid_findCriteria">Search for records</label>
</div>
<div style="height: 100%;">
<input tabindex="0" class="ms-crm-Dialog-Lookup-QuickFind" id="crmGrid_findCriteria" type="text" maxlength="100" hintlabelid="crmGrid_findHintText" value="" >
</div>
</td>
<td class="AppQuickFind_Render_td" nowrap="">
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_findCriteriaButton" href="#" target="_self">
<img title="Start search" class="ms-crm-ImageStrip-search " id="crmGrid_findCriteriaImg" alt="Start search" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-1172914485" imgbase="/_imgs/search"></a>
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_clearCriteriaButton" style="display: none;" href="#" target="_self">
<img title="Clear search" id="crmGrid_clearCriteriaImg" alt="Clear search" src="/_imgs/searchclear.gif" imgbase="/_imgs/searchclear">
</a>
</td>
</tr>
</tbody>
</table>
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This is the HTML code that I'm inspecting

Code:
<table width="100%" title="Use asterisk (*) wildcard character to search on partial text" cellspacing="0" cellpadding="0"><tbody>	<tr id="crmGrid_quickFindContainer" gridid="crmGrid">
		<td valign="top" style="width: 100%; overflow: hidden;"><div style="position: relative;">
			<label class="ms-crm-Dialog-Lookup-QuickFindHint ms-crm-TextAutoEllipsis" id="crmGrid_findHintText" style="display: inline;" for="crmGrid_findCriteria">Search for records</label>
		</div>
		<div style="height: 100%;">
			<input tabindex="0" class="ms-crm-Dialog-Lookup-QuickFind" 					id="crmGrid_findCriteria" type="text" maxlength="100" 						hintlabelid="crmGrid_findHintText" value="" >
		</div>
		</td>
		<td class="AppQuickFind_Render_td" nowrap="">
			<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_findCriteriaButton" href="#" target="_self">
				<img title="Start search" class="ms-crm-ImageStrip-search " id="crmGrid_findCriteriaImg" alt="Start search" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-1172914485" imgbase="/_imgs/search"></a>
		<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_clearCriteriaButton" style="display: none;" href="#" target="_self">
		<img title="Clear search" id="crmGrid_clearCriteriaImg" alt="Clear search" src="/_imgs/searchclear.gif" imgbase="/_imgs/searchclear">
			</a>
		</td>
	</tr>
</tbody>
</table>
 
Upvote 0
<table width="100%" title="Use asterisk (*) wildcard character to search on partial text" cellspacing="0" cellpadding="0"><tbody>
<tr id="crmGrid_quickFindContainer" gridid="crmGrid">
<td valign="top" style="width: 100%; overflow: hidden;"><div style="position: relative;">
<label class="ms-crm-Dialog-Lookup-QuickFindHint ms-crm-TextAutoEllipsis" id="crmGrid_findHintText" style="display: inline;" for="crmGrid_findCriteria">Search for records</label>
</div>
<div style="height: 100%;">
<input tabindex="0" class="ms-crm-Dialog-Lookup-QuickFind" id="crmGrid_findCriteria" type="text" maxlength="100" hintlabelid="crmGrid_findHintText" value="" >
</div>
</td>
<td class="AppQuickFind_Render_td" nowrap="">
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_findCriteriaButton" href="#" target="_self">
<img title="Start search" class="ms-crm-ImageStrip-search " id="crmGrid_findCriteriaImg" alt="Start search" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-1172914485" imgbase="/_imgs/search"></a>
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_clearCriteriaButton" style="display: none;" href="#" target="_self">
<img title="Clear search" id="crmGrid_clearCriteriaImg" alt="Clear search" src="/_imgs/searchclear.gif" imgbase="/_imgs/searchclear">
</a>
</td>
</tr>
</tbody>
</table>
 
Upvote 0
<table width="100%" title="Use asterisk (*) wildcard character to search on partial text" cellspacing="0" cellpadding="0"><tbody>
<tr id="crmGrid_quickFindContainer" gridid="crmGrid">
<td valign="top" style="width: 100%; overflow: hidden;"><div style="position: relative;">
<label class="ms-crm-Dialog-Lookup-QuickFindHint ms-crm-TextAutoEllipsis" id="crmGrid_findHintText" style="display: inline;" for="crmGrid_findCriteria">Search for records</label>
</div>
<div style="height: 100%;">
<input tabindex="0" class="ms-crm-Dialog-Lookup-QuickFind" id="crmGrid_findCriteria" type="text" maxlength="100" hintlabelid="crmGrid_findHintText" value="" >
</div>
</td>
<td class="AppQuickFind_Render_td" nowrap="">
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_findCriteriaButton" href="#" target="_self">
<img title="Start search" class="ms-crm-ImageStrip-search " id="crmGrid_findCriteriaImg" alt="Start search" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-1172914485" imgbase="/_imgs/search"></a>
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_clearCriteriaButton" style="display: none;" href="#" target="_self">
<img title="Clear search" id="crmGrid_clearCriteriaImg" alt="Clear search" src="/_imgs/searchclear.gif" imgbase="/_imgs/searchclear">
</a>
</td>
</tr>
</tbody>
</table>
 
Upvote 0
Hi,

I'm trying to integrate our Excel Tool to our customer information database to quickly search for information. I was able to control some of the hyperlinks and button I just want to ask some help on how I can auto fill the the input Search Box in the website that we're using in our office.

Sub crm()

'On Error Resume Next

Dim MyHTML_Element As IHTMLElement
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInputs As MSHTML.IHTMLElementCollection
Dim HTMLInput As IHTMLElement
Dim elements As MSHTML.IHTMLElementCollection

IE.navigate "10.163.74.252/ProView/main.aspx#"
IE.Visible = True


Do
DoEvents
Loop Until IE.readyState = 4

Set HTMLDoc = IE.document

Set Allhyperlinks = IE.document.getElementsByTagName("nobr")
For Each hyper_link In Allhyperlinks
If hyper_link.innerText = "Provider" Then
hyper_link.Click
Exit For
End If
Next

Do
DoEvents
Loop Until IE.readyState = 4

Set aAllhyperlinks = IE.document.getElementsByTagName("A")
For Each hyper_link In aAllhyperlinks
If hyper_link.innerText = "Contacts" Then
hyper_link.Click
Exit For
End If
Next


Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop

Set HTMLInput = HTMLDoc.getElementById("crmGrid_findCriteria")
HTMLInput.Value = "12546892"



End Sub


HTML Code
________________________________________________________________________________________________

<--------------/><table width="100%" title="Use asterisk (*) wildcard character to search on partial text" cellspacing="0" cellpadding="0"><tbody>
<tr id="crmGrid_quickFindContainer" gridid="crmGrid">
<td valign="top" style="width: 100%; overflow: hidden;"><div style="position: relative;">
<label class="ms-crm-Dialog-Lookup-QuickFindHint ms-crm-TextAutoEllipsis" id="crmGrid_findHintText" style="display: inline;" for="crmGrid_findCriteria">Search for records</label>
</div>
<div style="height: 100%;">
<input tabindex="0" class="ms-crm-Dialog-Lookup-QuickFind" id="crmGrid_findCriteria" type="text" maxlength="100" hintlabelid="crmGrid_findHintText" value="" >
</div>
</td>
<td class="AppQuickFind_Render_td" nowrap="">
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_findCriteriaButton" href="#" target="_self">
<img title="Start search" class="ms-crm-ImageStrip-search " id="crmGrid_findCriteriaImg" alt="Start search" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-1172914485" imgbase="/_imgs/search"></a>
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_clearCriteriaButton" style="display: none;" href="#" target="_self">
<img title="Clear search" id="crmGrid_clearCriteriaImg" alt="Clear search" src="/_imgs/searchclear.gif" imgbase="/_imgs/searchclear">
</a>
</td>
</tr>
</tbody>
</table>--------------------
 
Upvote 0
<table width="100%" title="Use asterisk (*) wildcard character to search on partial text" cellspacing="0" cellpadding="0"><tbody>
<tr id="crmGrid_quickFindContainer" gridid="crmGrid">
<td valign="top" style="width: 100%; overflow: hidden;"><div style="position: relative;">
<label class="ms-crm-Dialog-Lookup-QuickFindHint ms-crm-TextAutoEllipsis" id="crmGrid_findHintText" style="display: inline;" for="crmGrid_findCriteria">Search for records</label>
</div>
<div style="height: 100%;">
<input tabindex="0" class="ms-crm-Dialog-Lookup-QuickFind" id="crmGrid_findCriteria" type="text" maxlength="100" hintlabelid="crmGrid_findHintText" value="" >
</div>
</td>
<td class="AppQuickFind_Render_td" nowrap="">
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_findCriteriaButton" href="#" target="_self">
<img title="Start search" class="ms-crm-ImageStrip-search " id="crmGrid_findCriteriaImg" alt="Start search" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-1172914485" imgbase="/_imgs/search"></a>
<a tabindex="0" class="ms-crm-FindButton" id="crmGrid_clearCriteriaButton" style="display: none;" href="#" target="_self">
<img title="Clear search" id="crmGrid_clearCriteriaImg" alt="Clear search" src="/_imgs/searchclear.gif" imgbase="/_imgs/searchclear">
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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