0

I'm writing a code to automatically fill some website with cells values:

Sub prueba()
Dim oIE As InternetExplorer: Set oIE = New InternetExplorer
Dim oDocument As HTMLDocument
Dim ECICOR As HTMLSelectElement
Dim i, j As Integer
Dim x As Long

oIE.Visible = True

oIE.Navigate "http://sirem.eci.geci/smcfs/console/login.jsp"


Do While oIE.readyState <> 4: DoEvents: Loop


With oDocument
Set oDocument = oIE.Document
End With
 
 
Call oDocument.parentWindow.execScript("window.parent.sc.postDummyFormForWindow('/smcfs/console/inventory.search');", "JScript")


Set ECICOR = oDocument.getElementById("enterpriseFieldObj")
ECICOR.Focus
ECICOR.Click
ECICOR.Value = "ECICOR"
ECICOR.FireEvent ("onChange")



oDocument.getElementsByClassName("unprotectedinput")(0).Value = Cells(i, 1)
oDocument.getElementsByTagName("a")(0).Click
oDocument.getElementsbyClassName("evenrow")(1).click

End Sub

So my problem is that my program doesn't do anything on the last line of the code and I don't know what problem it is because it worked before.

Here you can see the HTML code:


<
<TR class=evenrow><TD class=checkboxcolumn><INPUT type=checkbox value=%3CInventoryItem+ItemID%3D%22000000000152030052%22+OrganizationCode%3D%22ECICOR%22+ProductClass%3D%22%22+UnitOfMeasure%3D%22%22%2F%3E name=EntityKey oldChecked="false"> <INPUT type=hidden value=000000000152030052 name=ItemID_1> <INPUT type=hidden name=UOM_1> <INPUT type=hidden name=PC_1> <INPUT type=hidden value=ECICOR name=OrgCode_1> </TD>
<TD class=tablecolumn><A onclick="javascript:showDetailFor('%3CInventoryItem+ItemID%3D%22000000000152030052%22+OrganizationCode%3D%22ECICOR%22+ProductClass%3D%22%22+UnitOfMeasure%3D%22%22%2F%3E');return false;" href="">000000000152030052</A> </TD>
<TD class=tablecolumn></TD>
<TD class=tablecolumn></TD>
<TD class=tablecolumn>001097578527174</TD></TR>">

How can I find a solution?

Petter
  • 27
  • 2
  • Does this answer your question? [How to click HTML link using VBA](https://stackoverflow.com/questions/61142348/how-to-click-html-link-using-vba) – MFerguson Dec 04 '21 at 23:45
  • `Cells(i, 1)` ?? Where is `i` assigned a value ? – CDP1802 Dec 05 '21 at 00:15
  • it is assigned already, that's not the problem sorry – Petter Dec 05 '21 at 01:38
  • The point is that I need to trigger this function: ```000000000152030052``` – Petter Dec 05 '21 at 01:54
  • "doesn't do anything on the last line of the code" Do you mean this line `oDocument.getElementsbyClassName("evenrow")(1).click` ? `evenrow` is a tr element and doesn't have an onClick event. – CDP1802 Dec 05 '21 at 13:03
  • And how could I click on this code? ```000000000152030052 ``` I tried with odocument.getelementsbytagname("a")(0).click, but doesn't work – Petter Dec 05 '21 at 17:17
  • Did you try `.FireEvent "onClick"` ? – CDP1802 Dec 05 '21 at 17:54
  • 1. The link in your post don't work. 2. IE is dead. It may be that the JS of the page cannot be executed in the IE at all. To check this, manually serve the page once in IE. If you can't execute the desired click there either, it won't work for IE with VBA either. If there is another event that needs to be triggered, you can check here how to find it and how to do it (FireEvent doesn't work most of the time) https://stackoverflow.com/questions/63294113/automate-ie-via-excel-to-fill-in-a-dropdown-and-continue/63299608#63299608 – Zwenn Dec 06 '21 at 12:58
  • This may help? https://stackoverflow.com/questions/54394442/vba-scraping-tr-onclick – Tragamor Dec 07 '21 at 17:25

0 Answers0