Unable to click "Search" button via VBA

shinigami_tianshi

New Member
Joined
Jun 11, 2018
Messages
7
Hi everyone

Currently I have a list of ID numbers in excel and wish to extract info from intranet. Prior to extract the data, I encountered error message when macro attempted to "click" the "Search" button in the webpage after have key in the ID number in the intranet fields.

The error message was : Run time error 91 Object variable or with block variable not set
Appears during the macro line : ie.Document.getElementById("search").Value.Click

Macro Code:
private Sub wpieautologin()


Dim ie As Object
Set ie = New SHDocVw.InternetExplorer
Set ie = CreateObject("Internetexplorer.Application")




ie.Navigate "intranet.com"
ie.Visible = True
Do
DoEvents


Loop Until ie.ReadyState = 4
ie.Document.getElementById("policyCode_text").Click
ie.Document.getElementById("policyCode_text").Value = "0026954693"
ie.Document.getElementById("search").Value.Click


End Sub

The following in the view source code for the intranet page on the "Search" button:

<td height="25" align="center" ><input value="Search" *******="if(checkNotNull()){transSubmitValue();}else {return false;}" class="button" type="submit" >
<input value="Exit" *******="if(checkNotNull()){transSubmitValue();javascript:goHome();return false;}else {return false;}" class="button" type="button" ></td>



Sincerely appreciate for help !
YH
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
In case that getElementById("search") select the item, then you you have to use
Code:
ie.Document.getElementById("search").Click
However without having access to the web page and its run time source code this is only a guess

Bye
 
Upvote 0
Hi Anthony

Sorry of the missing source code, as attached below:
<td height="25" align="center" ><input value="Search" *******="if(checkNotNull()){transSubmitValue();}else {return false;}" class="button" type="submit" >
<input value="Exit" *******="if(checkNotNull()){transSubmitValue();javascript:goHome();return false;}else {return false;}" class="button" type="button" ></td>
</tr>
</table></td>
</tr>

Appreciate for your help!

Best regards
YH
 
Upvote 0
<input value="Search" *******="if(checkNotNull()){transSubmitValue();}else {return false;}" class="button" type="submit" >
<input value="Exit" *******="if(checkNotNull()){transSubmitValue();javascript:goHome();return false;}else {return false;}" class="button" type="button" >
 
Upvote 0
I am sorry about the repeated attempts of pasting the source code, it turns out as an icon :(

Please find source code as below:
<<td height="25" align="center" >><<input value="Search" *******="if(checkNotNull()){transSubmitValue();}else {return false;}" class="button" type="submit" >>
<<input value="Exit" *******="if(checkNotNull()){transSubmitValue();javascript:goHome();return false;}else {return false;}" class="button" type="button" >><</td>>

Thank you very much!
 
Upvote 0
I mean th HTML source code, that you can read using the "Inspect" command of your browser, and include the html tags that might be used to grab the elements

Bye
 
Upvote 0
Thanks Anthony!

Please find the source code as below:
<html>
<INPUT *******="if(checkNotNull()){transSubmitValue();}else {return false;}" class=button type=submit value=Search>
<html>
Thank you very much!!
 
Upvote 0
I tried to include the html tag, but somehow it appears the button search.... :(


source code :
INPUT *******="if(checkNotNull()){transSubmitValue();else {return false;}
class=button, type=submit value=Search

Not sure if this helps.
Thank you very much
 
Upvote 0
This is not a html source code.
As I said, without having access to the web page we can only rely an what you publish.
Rightclick on the button and select Inspect (this is for Chrome); this will give you access to the html code of the area. From the code we need to understand how the button can be addressed, so I cannot be specific on what you have to look for. Try copying most of the source code pertaining the button.
Unless you can share the page Url and it is accessible to us...

Bye
 
Upvote 0
Hi Anthony

I am very sorry on the late reply. I have used the chrome and click on the inspect to copy the code as below:

HTML:
<form name="form1" action="/ls/qry/commonquery.CommonQuery.do" method="post"><table width="100%" border="0" cellspacing="0" cellpadding="0">  <tbody><tr>     <td align="center" valign="top">	  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">       <tbody><tr>        <td height="20" valign="bottom" class="font6">Common Query</td>       </tr>  <tr>    <td height="25" align="center" valign="middle"><hr size="1" noshade=""></td>  </tr>  <tr>    <td height="25" align="center" valign="middle">	<table width="95%" border="0" cellspacing="0" cellpadding="0">      <tbody><tr>        <td align="center" valign="top">		   <table width="97%" border="0" cellspacing="0" cellpadding="0">            <tbody><tr class="font3">              <td width="30%" height="30">Search Criteria</td>              <td width="70%" class="font7"></td>            </tr>           <tr class="font3">              <td height="30"><input id="policyCodeRadio" name="qryType" value="1" type="radio"><label for="policyCodeRadio">
                Policy No.</label></td>              <td class="font7"><font class="star">  </font><input type="hidden" name="policyCode" value=""><input errorlenmsg="The code length be too long,please input again!" codelength="10" typecode="11" class="textfiled" originalname="policyCode" errormsg="Invalid Policy No" type="text" originalvalue="" size="26" trans="policy" onblur="if(validateCodeLength(event)&&validateDocCode(event)){processPolicy(event);}" name="policyCode_text" value="" *******="makeRadioChecked(form1.policyCodeRadio);" nullmsg="The policy code can't be empty!" autocomplete="off">              <!--Field:policyCode name = "policyCode"  size="26"  /--></td>            </tr>            <tr class="font3">              <td height="30"><input id="propoalCodeRadio" name="qryType" value="2" type="radio"><label for="propoalCodeRadio">
                Proposal No.</label></td>              <td class="font7"><font class="star">  </font><input type="hidden" name="propoalCode" value=""><input errorlenmsg="The code length be too long,please input again!" codelength="10" typecode="22" class="textfiled" originalname="propoalCode" errormsg="Invalid Proposal No" type="text" originalvalue="" size="26" trans="apply" onblur="if(validateCodeLength(event)&&validateDocCode(event)){processApply();}" name="propoalCode_text" value="" *******="makeRadioChecked(form1.propoalCodeRadio);" nullmsg="The apply code can't be empty!" autocomplete="off"></td>            </tr>            <tr class="font3">              <td height="30"><input id="partyNameRadio" name="qryType" value="4" type="radio"><label for="partyNameRadio">
                Party Name</label></td>              <td class="font7"><font class="star">  </font><input onblur="Upper(this);" name="partyNameDisp" value="" class="textfiled" *******="makeRadioChecked(form1.partyNameRadio);" nullmsg="This value can't be empty!" type="text" size="26" autocomplete="off"></td>            </tr>            <tr class="font3">              <td height="30"><input id="partyCodeRadio" name="qryType" value="3" type="radio"><label for="partyCodeRadio">
                Party ID No.</label></td>              <td class="font7"><font class="star">  </font><input onblur="Upper(this);" name="partyCode" value="" class="textfiled" *******="makeRadioChecked(form1.partyCodeRadio);" nullmsg="This value can't be empty!" type="text" size="26" autocomplete="off"></td>            </tr>            <tr class="font3">              <td height="30"><input id="grioAccountRadio" name="qryType" value="5" type="radio"><label for="grioAccountRadio">
                GIRO Account No.</label></td>              <td class="font7"><font class="star">  </font><input name="grioAccount" value="" class="textfiled" *******="makeRadioChecked(form1.grioAccountRadio);" nullmsg="This value can't be empty!" type="text" size="26" autocomplete="off"></td>            </tr>            <tr class="font3">              <td height="30"><input id="creditCardRadio" name="qryType" value="6" type="radio"><label for="creditCardRadio">
                Credit Card Account</label></td>              <td class="font7"><font class="star">  </font><input name="creditCard" value="" class="textfiled" *******="makeRadioChecked(form1.creditCardRadio);" nullmsg="This value can't be empty!" type="text" size="26" autocomplete="off"></td>            </tr>            <!-- FPMS_ICCF_32118/asc_ukw/GELM-RSA-2017-01994-FPMS-DD5 -->                        <tr class="font3">              <td height="30"><input id="carRegistrationNoRadio" name="qryType" value="7" type="radio"><label for="carRegistrationNoRadio">
                Car Registration No.</label></td>              <td class="font7"><font class="star">  </font><input name="carRegistrationNo" value="" class="textfiled" *******="makeRadioChecked(form1.carRegistrationNoRadio);" nullmsg="This value can't be empty!" type="text" size="26" autocomplete="off"></td>            </tr>            <!--SharadM: Commented for GELM-RSA-2013-03126-FPMS, SIT Defect U17589 -->            <!-- tr class="font3">              <td height="30" ><input id="iacRadio" name="qryType" value="8" type="radio" ><label for="iacRadio">
                IAC No.</label></td>              <td class="font7"><font class="star">  </font><input name="iac" value="" class="textfiled" *******="makeRadioChecked(form1.iacRadio);" nullMsg="This value can't be empty!" type="text" size="26" ><!--Field:codeTable name="iac" tableName="T_AGENT" style="ONE_TEXTBOX" size="26"/></td>            </tr-->                                    <tr class="font3">              <td width="30%" height="30">Claims Information</td>              <td width="70%" class="font7"></td>            </tr>             <tr class="font3">              <td height="30"><input id="insuredCodeRadio" name="qryType" value="10" type="radio"><label for="insuredCodeRadio">                ID Number</label></td>              <td class="font7"><font class="star">  </font><input name="insuredCode" value="" class="textfiled" *******="makeRadioChecked(form1.insuredCodeRadio);" nullmsg="This value can't be empty!" type="text" size="26" autocomplete="off"><!--Field:codeTable name="iac" tableName="T_AGENT" style="ONE_TEXTBOX" size="26"/--></td>            </tr>            <!--add by sunrain for new requirement -->            <tr class="font3">               <td width="30%" height="30">Risk Aggregation Infomation</td>               <td width="70%" class="font7"></td>            </tr>            <tr class="font3">              <td height="30"><input id="riskCodeRadio" name="qryType" value="55" type="radio"><label for="riskCodeRadio">Life Assured ID No</label></td>              <td class="font7"><font class="star">  </font><input name="riskCode" value="" class="textfiled" *******="makeRadioChecked(form1.riskCodeRadio);" nullmsg="This value can't be empty!" type="text" size="26" autocomplete="off"></td>            </tr>            <tr class="font3">              <td height="30"><input id="riskPolicyCodeRadio" name="qryType" value="56" type="radio"><label for="riskPolicyCodeRadio">
                Policy No.</label></td>              <td class="font7"><font class="star">  </font><input type="hidden" name="riskPolicyCode" value=""><input errorlenmsg="The code length be too long,please input again!" codelength="10" typecode="11" class="textfiled" originalname="riskPolicyCode" errormsg="Invalid Policy No" type="text" originalvalue="" size="26" trans="policy" onblur="if(validateCodeLength(event)&&validateDocCode(event)){processPolicy(event);}" name="riskPolicyCode_text" value="" *******="makeRadioChecked(form1.riskPolicyCodeRadio);" nullmsg="The policy code can't be empty!" autocomplete="off"></td>            </tr>        </tbody></table></td>      </tr>      <tr>        <td height="25" align="center"><input value="Search" *******="if(checkNotNull()){transSubmitValue();}else {return false;}" class="button" type="submit">          <input value="Exit" *******="if(checkNotNull()){transSubmitValue();javascript:goHome();return false;}else {return false;}" class="button" type="button"></td>      </tr>    </tbody></table></td>  </tr>          
  <tr>    <td height="25"><hr size="1" noshade=""></td>  </tr>  <tr>    <td height="25"></td>  </tr></tbody></table>	  </td>  </tr></tbody></table></form>

The Url is https://fpms-sg.greateasternlife.com/ls/qry/commonquery.CommonQuery.do, but i doubt it can be accessed as this is an intranet.

Thanks in advance for your help!!
Best regards
YH
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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