使用VBA Excel在iFrame中单击下拉选项 [英] Clicking a drop down option in iFrame with VBA excel
问题描述
我正在尝试单击以下代码中的下拉选项批准交易".我有扎实的VBA背景知识,但这是我第一次尝试使用VBA excel实现HTML自动化.到目前为止,我已经能够导航并登录到网站,选择需要批准的交易,并显示下拉列表.但是,我无法弄清楚如何单击下拉选项/触发事件.我相信我的空白正在处理iFrame和/或表格(到目前为止,我在代码中不必处理的事情)
I'm trying to click the drop down option "Approve the Deal" in the below code. I have solid VBA backround but this is my first attempt at HTML automation with VBA excel. Thus far I'm able to navigate and login to the website, select the deal that needs to be approved, and show the drop down. However, I cannot figure out how to click the drop down option/trigger the event. I believe my gaps are dealing with the iFrame and/or table (something I did not have to deal with in the code to this point)
我已经测试了许多不同的Web查找代码,因此我不会反悔我遇到的每一个副本/粘贴修改过的故障.下面是我尝试与之交互的代码.我正在尝试点击/触发批准交易".
I have tested a lot of different web found code so I won't regurgitate every copy/pasted modied failure I've had. Below is the code I'm attempting to interact with. The "Approve the Deal" is what I'm trying to click/trigger.
在此先感谢您提供的任何建议!
Thank you in advance for any advice you could provide!
经过编辑,在下面包含HTML和我的代码.我一直在删除无法正常工作的东西,只是插入并播放不同的选项.我确定的那篇文章很可能是错误的.
Edited to include HTML and my code below. I have been deleting non working things and just plugging and playing different options. The piece I identified is likely very wrong.
<IFRAME id=VCommonBlockerVxActionMenu_68_SUPPORT style="BORDER-TOP: 0px; HEIGHT: 62px; BORDER-RIGHT: 0px; WIDTH: 98px; BORDER-BOTTOM: 0px; POSITION: absolute; LEFT: 1402px; FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0); BORDER-LEFT: 0px; Z-INDEX: 12; DISPLAY: block; TOP: 98px; BACKGROUND-COLOR: #ffffff; 0: " src="javascript:false" frameBorder=0 scroll="no"></IFRAME>
<DIV id=VxActionMenu_68_SUPPORT class=VDropDown_support style="HEIGHT: 62px; WIDTH: 98px; LEFT: 1402px; Z-INDEX: 13; DISPLAY: inline; TOP: 98px"><TABLE id=VxActionMenu_68_OPTIONS class=VDropDown_options style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0>
<COLGROUP>
<COL width=22></COL>
<COL width="100%"></COL>
<COL width=22></COL>
<TBODY>
<TR onmouseover=VPage.VxActionMenu_68.hilite(event); onmousedown=VPage.VxActionMenu_68.select(event); class="VDropDown_hiderow VDropDown_option" vvalue="null">
<TD class=VDropDown_leftimg> </TD>
<TD class=VDropDown_option>More Actions</TD>
<TD class=VDropDown_rightimg> </TD></TR>
<TR onmouseover=VPage.VxActionMenu_68.hilite(event); onmousedown=VPage.VxActionMenu_68.select(event); class="VDropDown_option VDropDown_select" vfixed="true" vupdateLabel="true" vjs="VxManager.invokeActionHandler('vx.actions.VxAgreement_CommitHandler,vx.actions.VxApprovable_Approve',{statusMsg: 'Approving...'}, {vx_wsid: 'WS3',okHandler:'vx.actions.VxAgreement_CommitHandler,vx.actions.VxApprovable_Approve',showDialog:'true',statusMsg:'Approving...'});">
<TD title="Approve the Deal" class=VDropDown_option colSpan=2><NOBR>Approve</NOBR></TD>
<TD class=VDropDown_rightimg><IMG src="http://venprd.na.odcorp.net/vendavo/images/icons/clear.gif" width=16 align=absBottom height=1></IMG></TD></TR>
<TR onmouseover=VPage.VxActionMenu_68.hilite(event); onmousedown=VPage.VxActionMenu_68.select(event); class=VDropDown_option vfixed="true" vupdateLabel="true" vjs="VxManager.invokeActionHandler('vx.actions.VxAgreement_CommitHandler,vx.actions.VxApprovable_Deny',{statusMsg: 'Denying...'}, {vx_wsid: 'WS3',okHandler:'vx.actions.VxAgreement_CommitHandler,vx.actions.VxApprovable_Deny',showDialog:'true',statusMsg:'Denying...'});">
<TD title="Deny the Deal" class=VDropDown_option colSpan=2><NOBR>Deny</NOBR></TD>
<TD class=VDropDown_rightimg><IMG src="http://venprd.na.odcorp.net/vendavo/images/icons/clear.gif" width=16 align=absBottom height=1></IMG></TD></TR>
<TR onmouseover=VPage.VxActionMenu_68.hilite(event); onmousedown=VPage.VxActionMenu_68.select(event); class=VDropDown_option vfixed="true" vupdateLabel="true" vjs="VxManager.invokeActionHandler('vx.publishing.VxPublishingDocActions_OpenOrNew',{statusMsg: 'Publishing...'}, {vx_wsid: 'WS3'});">
<TD title="Create a document from the deal" class=VDropDown_option colSpan=2><NOBR>Publish</NOBR></TD>
<TD class=VDropDown_rightimg><IMG src="http://venprd.na.odcorp.net/vendavo/images/icons/clear.gif" width=16 align=absBottom height=1></IMG></TD></TR></TBODY></TABLE></DIV>
我还有另一个工作组来导航到网站并登录.
I have another working sub to navigate to the website and login.
Sub VendavoApprove()
Dim elmButton As MSHTML.IHTMLElement
'Activate previously opened Vendavo page
'Set shellWins = New SHDocVw.ShellWindows
'For Each explorer In shellWins
'If explorer.Name = "Internet Explorer" Then
'Debug.Print explorer.LocationURL
'Debug.Print explorer.LocationName
'End If
'Next
'Set shellWins = Nothing
'Set explorer = Nothing
AppTitle = "Powered by Vendavo"
AppActivate AppTitle
Set oApp = CreateObject("Shell.Application")
For i = 0 To 25
strName = ""
On Error Resume Next
strName = oApp.Windows(i).document.URL
If InStr(strName, "http://venprd.na.odcorp.net/vendavo/pc?page=vx.core.BasicPage&menuId=deals&folderId=quotes") Then
Set oIE = oApp.Windows(i)
Exit For
End If
Next
oIE.Visible = True
oIE.document.all("VTree_VxFolderNav_deals.13.icon").Click
oIE.document.all("table_VxCanvasListing_inner_1_COL_1_FILTER").Click
oIE.document.all("table_VxCanvasListing_inner_COL_1_FILTER").Click
oIE.document.all("table_VxCanvasListing_inner_1_FILTER_VALUE1").Value = 9792365
oIE.document.all("table_VxCanvasListing_inner_FILTER_VALUE1").Value = 9792365
oIE.document.all("id1_label").Click
oIE.document.all("table_VxCanvasListing_inner_1$x0_ROWHDR").Click
'oIE.document.all("table_VxCanvasListing_inner_1_ActionMenus_LABEL").Click
oIE.document.all("table_VxCanvasListing_inner_1$x0_1").FireEvent "ondblclick", 1, 2
oIE.document.all("table_VxCanvasListing_inner$x0_1").FireEvent "ondblclick", 1, 2
oIE.document.getElementById("VxActionMenu_68_LABEL").Click 'Dynamic
oIE.document.getElementById("VxActionMenu_67_LABEL").Click 'Dynamic
oIE.document.getElementById("VxActionMenu_237_LABEL").Click 'Dynamic
'Approve the core - this is the part I'm working on
Set htm = oIE.document.frames("VCommonBlockerVxActionMenu_68_SUPPORT").document
Set frms = htm.forms("TargetForm")
Set Class1 = frms.document.getElementsByTagName("VxActionMenu_68_OPTIONS")
For Each inputelement In Class1
If inputelement.getAttribute("title") = "Approve the Deal" Then
inputelement.Click
Exit For
End If
Next
'ending here
oIE.document.all("VxApprovableComments_71_COMMENT").Value = "Approved"
oIE.document.all("id1_label").Click
End Sub
推荐答案
tr似乎位于iframe外部,并且具有mousedown事件,您可以尝试附加和触发.我的目标是tr的vjs属性.
Looks like tr is outside an iframe and has a mousedown event you can try attaching and firing. I'm targeting the vjs attribute of the tr.
Dim evt As Object
Set evt = .document.createEvent("HTMLEvents")
evt.initEvent "mousedown", True, False
oIE.document.querySelector("[vjs*=VxApprovable_Approve]").dispatchEvent evt
这篇关于使用VBA Excel在iFrame中单击下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!