VBA getElementById与动态ID [英] VBA getElementById with dynamic ID
本文介绍了VBA getElementById与动态ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在搜索这个整个论坛,msdn和专门的教程,我找不到VBA的答案:
如何使 getElementById
在访问VBA模块中工作,其中找到的id是动态的?
I've been searching this whole forum, msdn and specialised tutorials and I can't find the answer for VBA:
How can I make the getElementById
work in an access VBA module where the id to find is dynamic?
让我们看看html代码:
Let's see the html code:
<DIV id=rowToolTipContainer>
<DIV class=contactsCard id=resultsTooltip1122286Contents style="DISPLAY: none">
<TABLE class="shadow-box tooltip">
<TBODY>
我正在尝试找到它:
Dim ResultDIV As HTMLDivElement
Set ResultDIV = HTMLDoc.getElementById("resultsTooltip*")
让我说,返回的html有不同的id(数字变化)取决于每个结果,所以每个DIV的id总是:
Let me say the html returned has a different id (the numbers change) depending on each result so the id for each DIV is always:
id = resultsTooltipxxxxxxxContents
其中 xxxxxxx
总是不同的数字
任何帮助将非常感激。
推荐答案
尝试这样的一个:
Dim ContainerDiv As HTMLDivElement, ResultDIV As HTMLDivElement
Set ContainerDiv = HTMLDoc.getElementById("rowToolTipContainer")
For Each ResultDIV In ContainerDiv.GetElementsByTagName("div")
If ResultDIV.ID Like "resultsTooltip*Contents" Then
'' What do you want to do here?
Exit For
End If
Next
这篇关于VBA getElementById与动态ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文