I will try to explain most fully. There is a label in Excel, there is a web database interface. There are no other possibilities how to interact with the database via the web. It is necessary to make a tabular data search in the web interface and pull out the missing data from it and put it in a tablet. Problem: I can not get objects to programmatically “click” the web interface - hpsm (local system). Version 9.40.3006-P3 looks like this: enter image description here

I want to click on terminal devices:

<div class="x-panel-header x-panel-header-noborder x-unselectable icon-micellaneous icon-hp x-accordion-hd" id="ext-gen-top115" tabindex="0" role="tab" aria-expanded="false" style="cursor: pointer;"><span class="x-panel-header-text" id="ext-gen-top119">Терминальные устройства</span></div> 

I do this:

 Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True IE.navigate ("http://mos-hpsm-wb.***********/hp/index.do") --ожидание загрузки --- Do While IE.Busy: Loop Do While IE.ReadyState <> 4: Loop obj = IE.Document.getElementById("ext-gen-top115") Do While IsNull(obj) ' это введено потому что предыдущие не отрабатывали, еще грузился контент, видимо из-за этого: "<body onload="cwc.getFrameworkWindow();cwc.setAppMode();" Sleep (100) obj = IE.Document.getElementById("ext-gen-top115") 'Debug.Print IsNull(obj) Loop '--ожидание загрузки obj = IE.Document.getElementById("ext-gen-top115") 

As a result, obj only gets the string name of the object that I want to use.

enter image description here

But if I get an item like this (that is, the same thing only by the class name):

 obj = IE.Document.getElementsByClassName("x-panel-header x-panel-header-noborder x-unselectable icon-micellaneous icon-hp x-accordion-hd") 

That's all good:

enter image description here

I do to him: obj.Click And the scroll is revealed:

enter image description here

What should I do to get items by ID? Help me please.

ps what I got by the name of classes is this object, so I understand “randomness” because I need to “click” further and I can’t get objects by name of classes. Generally need by ID.

Thanks a lot in advance!

  • What an ancient witch. The code looks right, it should return an element, I can only assume that the variable is incorrectly cast. Maybe there Set retobj = IE.Document.getElementById ("ext-gen-top115") try to save to a new variable. I do not even know. - Alex Krass
  • Yes, you were right. Set obj ... straightened. Thank! - Artem

1 answer 1

Structuring a question gives rise to a solution. :) Answer:

 Dim obj As Object Set obj = IE.Document.getElementById("ext-gen-top115") obj.Click 

Thanks to the resource! :)