1

我正在尝试使用 IE 在 excel 中自动填写公司内部网络上的网络表单。我之前的问题是针对动态元素 ID,感谢 SIM解决了这个问题(再次感谢!)不幸的是,我不能使用相同的方法继续;使用下面的代码,我可以打开 url 并单击动态元素,这会打开新窗口,但是我没有运气识别要单击的属性/元素。

Sub Route4b()
Dim ie As New InternetExplorer, Html As HTMLDocument
With ie
    .Visible = True
    .navigate "https://company.application.com/home/index.cfm?Tab=home"
    While .Busy = True Or .readyState < 4: DoEvents: Wend
    Set Html = .document
End With
For Each elem In Html.getElementsByClassName("clickable")
If InStr(elem.innerText, "Inspection") > 0 Then elem.Click: Exit For
Next elem
While ie.Busy Or ie.readyState <> READYSTATE_COMPLETE
    DoEvents
Wend
For Each elem In Html.getElementsByClassName("inspection-font clickable")
If InStr(elem.innerText, "EU KSR - Dock") > 0 Then elem.Click: Exit For
Next elem
While ie.Busy Or ie.readyState <> READYSTATE_COMPLETE
    DoEvents
Wend
End Sub

代码运行时没有错误消息,它只是不执行第二次内文点击。

下面还有 html 代码,唯一的唯一属性是跨度标题和内部文本,跨度类共享许多不同的“跨度标题”(比如 10 个)。

动态链接

    <input name="tblheaderupcoming" id="tblheaderupcoming" type="hidden" value="["","Checklist","Assigned To","Due Date","Frequency",""]"/>
    <div class="card table-card data-table mb-0">
     <div class="card-header bg-secondary pointer rendered-toggle card-status card-status-upcoming" aria-expanded="true" href="#cardupcoming" data-togle="collapse" data-id="upcoming" data-priority="2">...</div>
     <div class="card-block dashboard-container collapse show" id="cardupcoming" aria-expanded="true">...</div>
      <div class="dataTables_wrapper dt-bootstrap4 no-footer" id="tableupcoming_wrapper">
       <div class="col-xs-6 px-2">...</div>
       <div class="col-xs-6 px-2">...</div>
       <table class="table table-bordered table-hover table-striped no-more-tables table-upcoming dataTable no-footer rendered-nmt" id="tableupcoming" role="grid" aria-describedby="tableupcoming_info">...</table>
        <thead>
         <tr class="bg-active" role="row">...</tr>
        </thead>
        <tbody>
         <tr class="odd" role="row">
          <td data/title=" "></td>
          <td data-title="Checklist">
           <div>
            <span title="EU KSR - Dock Audit Type:OPS Calibration - KSR" class="inspection-font clickable" onclick="window.open('goto_pit.cfm?samid=3053960&siteid=882&thestatus=upcoming');">EU KSR - Dock</span>

任何帮助将不胜感激,我尽可能多地搜索,但没有找到任何我可以申请的东西。并为残疾道歉以更清晰的方式表达它,我充其量是业余爱好者。非常感谢!

4

0 回答 0