【问题标题】:click button in IE with VBA (excel 2016)单击带有 VBA 的 IE 中的按钮(excel 2016)
【发布时间】:2017-08-04 17:44:37
【问题描述】:

我想单击保存按钮,但无法正确引用它以便 VBA 在网页上找到它。我在图像中附加了 HTML 代码,我涂黑了几个部分。我已经在网上搜索并尝试了许多标注来访问此按钮,但 VBA 仍然找不到它。使用 DOM 资源管理器将按钮显示为图像中的蓝色突出显示线。

我可以 SendKeys("TAB") 直到我到达按钮,然后发送一个通用的点击动作,还是我必须按名称引用元素才能点击它?如何引用此保存按钮?我感谢您的帮助。

HTML Code image

HTML

<html> 
<head>...</head>
<frameset rows="100%,*" cols="*" frameBorder="no" frameSpacing="0" › <frame srcar frameBorder="NO" marginWidth="0" marginHeight="0" scrolling="auto">
    <frame src="" frameBorder="NO" marginWidth="0" marginHeight="0" scrolling="auto">
    <html> 
    <head>...</head>

    <body aLink="white" onload="readValues(0)" onresize="null">
        <form name="frmRptRetrieval" action="" encType="" mehotd="post">
        <table width="100%" height="5%" bgColor="•191667" border="0" cellSpacing="0" cellPadding="0">...</table>
        <table width="100%" align="center" border="0">...</table>
        <img width="20" height="20" alt="notification.gif" src="../images/notification.gif"></img>
        <font color="green">Report Retrieval Query saved successfully.</font>
        <table width="780" align="center" border="0">
            <tbody>
               <tr>
                 <td align="left" rowSpan="1" colSpan="1">
                    <table width="100%" align="center" border="0">
                      <tbody>  
                        <tr vAlign="top">...</tr>
                        <tr>
                            <td align="center" rowSpan="1" colSpan="1" › <a href="javascript:doSubmit();" shape="">
                             <img height="18" src="../images/btn_Save.gif" border="0"></img>
                                </a>
                                <a href="javascript:clearAll();" shape="">...</a>

【问题讨论】:

    标签: html vba


    【解决方案1】:

    试试这个:

    Dim objIE As SHDocVw.InternetExplorer
    Set objIE = CreateObject("InternetExplorer.Application")
         objIE.navigate "YOUR_URL"
    objIE.navigate objIE.document.frames(0).document.getelementsbyname("frmRptRetrieval")(0).document.getelementsbytagname("a")(XXXX).href
    

    现在:您的工作是在具有标记名“a”的元素列表中找到按钮的位置,并将 XXXX 替换为此位置 1(因为索引)。

    【讨论】:

    • 我会试试这个,如果我能正常工作,会告诉你。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-18
    相关资源
    最近更新 更多