简体   繁体   English

如何使用Excel VBA单击Web CSS按钮?

[英]How to use Excel VBA to click a web CSS button?

I am creating a macro with Excel VBA that will submit an entry into an online database using information from an Excel spreadsheet. 我正在使用Excel VBA创建一个宏,该宏将使用Excel电子表格中的信息将条目提交到在线数据库中。 During this entry process, the macro needs to click on a CSS button. 在此输入过程中,宏需要单击CSS按钮。 It isn't a form button, does not have an input type, no name, no id, and no source image except for a background image. 它不是一个表单按钮,没有输入类型,没有名称,没有ID,除了背景图像外没有任何源图像。 I think my only hopes are either to click on the button based on the div class. 我认为我唯一的希望是单击基于div类的按钮。 Can anyone help? 有人可以帮忙吗? The button is here : 该按钮在这里:

<div class="v-captiontext">
    By Ankit
</div>
<td class="v-tabsheet-tabitemcell v-tabsheet-tabitemcell-selected" style="">
    <div class="v-         tabsheet-tabitem v-tabsheet-tabitem-selected">
        <div class="v-caption" style="width: 39px;">
            <div class="v-captiontext">
                By LOT</div>
            <div class="v-caption-clearelem">
            </div>
        </div>
    </div>
</td>

Thanks to Remou's answer on this thread: Use VBA code to click on a button on webpage 感谢Remou在此主题上的回答: 使用VBA代码单击网页上的按钮

Here is a first stab in your issue, you could try this: 这是您问题中的第一个刺,您可以尝试以下方法:

Set tags = wb.Document.GetElementsByTagname("div")

For Each tagx In tags
    If tagx.class = "v-caption-clearelem" Then
        tagx.Click
    End If
Next

Yet, I've never tried to use the Click method on a div. 但是,我从未尝试在div上使用Click方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM