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
 
I am sorry, but I was not able to identify which of the source code refers to the button you wish to click.

Try re-inspecting the button and attach the elements associated to it; when you select a code, Chrome will show which element it pertains.

Bye
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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