VBA点击鼠标悬停菜单。

时间:2021-02-15 14:13:43

I've got a request similar to this question here, and I've just found and am looking into this request here as well. I'm trying to build a VBA macro to scrape some web data, and I've gotten through the login screen but now I'm stuck as the page seems to be written in javascript and I'm completely unfamiliar with how to work with it. I'm pretty fuzzy with HTML and have been just teaching myself as I'm going. Below is my VBA so far, with the canceled code lines showing what I've tried that didn't work. What I'm trying to do is click a link to 'Reports' which is under a dropdown menu called 'My Sequentra' activated by onmouseover. Thank you for your help.

我有一个类似于这个问题的请求,我刚刚发现并正在这里寻找这个请求。我正在尝试构建一个VBA宏来获取一些web数据,我已经通过了登录界面,但是现在我被困住了,因为页面似乎是用javascript编写的,我对如何使用它完全不熟悉。我对HTML很模糊,一直在自学。下面是我的VBA,已经取消的代码行显示了我尝试过的无效。我要做的是点击“报告”的链接,该链接位于onmouseover激活的名为“My Sequentra”的下拉菜单下。谢谢你的帮助。

Sub SingleSiteReportPull()

Dim ie As Object
Dim form As Variant, button As Variant

Set ie = CreateObject("InternetExplorer.Application")

'''''Set input boxes for username, password, & site to pull report for'''''
myusername = InputBox("Enter Your Sequentra Username")
mypassword = InputBox("Enter Your Sequentra Password")
searchsite = InputBox("Which site would you like to pull a report for?")

'''''Go to webpage'''''
With ie
.Visible = True
.navigate ("https://www.sequentra.net/seq-security/ssoLogin.go")

While ie.ReadyState <> 4
    DoEvents
Wend

'''''enter username & password'''''
On Error Resume Next

ie.document.getelementsbyname("j_username").Item.innertext = myusername
ie.document.getelementsbyname("j_password").Item.innertext = mypassword 

'''''submit login info'''''
With appIE
    ie.document.forms(0).submit
End With

'''''click through menus to reports'''''   
'Set frms = ie.document.getelementsbyTagname("FORM")
'Set button = form(0).onsubmit
'form(0).submit

'Set link = ie.document.getelementsbytagname("a")
'For Each l In link
 '   If link.classname = "appReportsShow.do" Then
   '     link.Click
    '    Exit For
    'End If
'Next l

'ie.documents.parentWindow.execScript "loadFrame('appReportsShow.do')", "JavaScript"

'Do While ie.busy: DoEvents: Loop

End With
Set ie = Nothing
End Sub

Here is the page source code I'm looking at:

这是我正在查找的页面源代码:

<li class="clsTopMenuItem active" onmouseover="expandTopMenu(this)" onmouseleave="collapseTopMenu(this)"><a href="javascript:void(0);">My Sequentra</a>                 
    <ul style="display: none;">                     
        <li class="clsSubMenu" onmouseover="expandMenu(this)" onmouseleave="collapseMenu(this)"><a onclick="loadFrame('javascript:goHome()', this, {isNewWindow: false, width:-1, height:-1})" href="javascript:void(0);">Home</a>
        </li>                               
        <li class="clsSubMenu" onmouseover="expandMenu(this)" onmouseleave="collapseMenu(this)"><a onclick="loadFrame('appReportsShow.do', this, {isNewWindow: false, width:-1, height:-1})" href="javascript:void(0);">Reports</a>
        </li>
        <li class="clsSubMenu" onmouseover="expandMenu(this)" onmouseleave="collapseMenu(this)"><a onclick="loadFrame('notificationMyAlertListShow.go', this, {isNewWindow: false, width:-1, height:-1})" href="javascript:void(0);">My Alerts</a>
        </li>
    </ul>                           
</li>

1 个解决方案

#1


1  

found a similar issue on ozgrid, used it as a base point and got it to click through. Solution below.

在ozgrid中发现了一个类似的问题,并将其作为基准点,让它点击通过。下面的解决方案。

ie.document.all.Item
Call ie.document.parentWindow.execScript("loadFrame('appReportsShow.do')", "JavaScript")
.Click

#1


1  

found a similar issue on ozgrid, used it as a base point and got it to click through. Solution below.

在ozgrid中发现了一个类似的问题,并将其作为基准点,让它点击通过。下面的解决方案。

ie.document.all.Item
Call ie.document.parentWindow.execScript("loadFrame('appReportsShow.do')", "JavaScript")
.Click