使用vba自动点击网站上的按钮

时间:2015-07-13 14:35:23

标签: vba

我正在尝试使用vba导航到网站,登录并在下拉框中进行选择。我坚持在下拉框中进行选择。要查看下拉列表,您必须单击图标按钮,然后单击导出到csv选项的选择。我相信图标按钮被称为rallybutton-1175,出现的下拉菜单是rallymenu-1225,我想在下拉列表中选择的选项是menuitem-1227。页面本身非常复杂,并且没有像提交按钮那样简单地引用按钮..

我已经尝试了几件事来点击这些“按钮”..

  doc.getElementById("rallymenu-1225").selectedindex=1
  doc.getElementById("rallymenu-1225").FireEvent("onchange")

  Call objIE.document.parentWindow.execScript("menduitem-1227", "JavaScript").Click

      With .document
     ' select action menu
       Set dropDownMenu = .getElementsByID("rallymenu-1225")
      Set dropDownMenu(1) = "menuitem-1227"

            End With

      Call objIE.document.parentWindow.execScript("menduitem-1219", "JavaScript").Click

             'click action menu icon
            Set htmlDoc = .document
            Set htmlColl = htmlDoc.getElementById("rallybutton-1175-btnIconEl")
            Do While htmlDoc.readyState <> "complete": DoEvents: Loop
                For Each htmlInput In htmlColl
                    If Trim(htmlInput.ID) = "rallybutton-1175-btnIconEl" Then
                        htmlInput.Click
                        Exit For
                    End If
                Next htmlInput

以下是我可以分享的代码......

   <div id="rallymenu-1225" class="x4-panel rally-menu no-icon x4-layer x4-panel-default x4-menu x4-menu-plain x4-border-box" style="width: 148px; height: 73px; right: auto; left: 1090px; top: 148px; z-index: 19001;"   tabindex="-1"> 
  <div id="rallymenu-1225-body" class="x4-panel-body x4-menu-body x4-unselectable x4-panel-body-default x4-box-layout-ct x4-panel-body-default" role="presentation" style="width: 148px; height: 73px; left: 0px; top: 0px;">
 <div class="x4-box-inner x4-box-scroller-top x4-box-scroller-plain" role="presentation">
 <div id="rallymenu-1225-before-scroller" class="x4-box-scroller x4-menu-scroll-top" style="display:none" role="presentation"></div>
<div id="rallymenu-1225-innerCt" class="x4-box-inner x4-vertical-box-overflow-  body" role="presentation" style="height: 73px; width: 148px;">
<div id="x4-gen1922" class="x4-menu-icon-separator" role="presentation"> </div>
<div id="rallymenu-1225-targetEl" class="x4-box-target" role="presentation"   style="width: 148px;">
<div id="menuitem-1226" class="x4-component x4-box-item x4-component-default x4-    menu-item" style="right: auto; left: 0px; top: 0px; margin: 0px;">
<div id="menuitem-1227" class="x4-component x4-box-item x4-component-default x4-   menu-item" style="right: auto; left: 0px; top: 25px; margin: 0px; width:   148px;">
<a id="menuitem-1227-itemEl" class="x4-menu-item-link " unselectable="on" hidefocus="true" role="presentation" href="#">
<span id="menuitem-1227-textEl" class="x4-menu-item-text" unselectable="on">Export to CSV...</span>

我也在这里发布了这个问题...... http://www.ozgrid.com/forum/showthread.php?t=195757

谢谢!

0 个答案:

没有答案