首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IE11框架通知栏-单击“保存”

IE11框架通知栏-单击“保存”
EN

Stack Overflow用户
提问于 2016-06-11 01:02:58
回答 1查看 1.5K关注 0票数 0

我被困在一个需要访问IE11中的框架通知栏的自动化过程中-我发现下面的代码很有用,但在行上收到了一个“类型不匹配”

H= ie.Hwnd

是不是因为我把IE声明为internetexplorermedium?

代码语言:javascript
复制
Option Explicit

Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long

Sub lime()
Application.DisplayAlerts = False
Dim ie As SHDocVw.InternetExplorer
Dim doc As HTMLDocument
Set ie = CreateObject("InternetExplorer.Application")
Set ie = New InternetExplorerMedium
ie.Visible = True
ie.Navigate ("http://xxx/")
Doodly ie
Muddly ie
Set doc = ie.Document

doc.getElementById("ctl32_ctl04_ctl03_ddValue").Value = "4"

doc.parentWindow.execScript "__doPostBack('ctl32$ctl04$ctl03$ddValue','')", "JavaScript"

Application.Wait (Now() + TimeValue("00:00:05"))

doc.getElementById("ctl32_ctl04_ctl05_ddValue").Value = "1"

doc.getElementById("ctl32_ctl04_ctl00").Click

Application.Wait (Now() + TimeValue("00:00:05"))

doc.parentWindow.execScript "$find('ctl32').exportReport('EXCELOPENXML')", "JavaScript"

Application.Wait (Now() + TimeValue("00:00:05"))


Dim o As IUIAutomation
Dim e As IUIAutomationElement
Set o = New CUIAutomation
Dim h As Long
h = ie.Hwnd
h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)
If h = 0 Then Exit Sub

Set e = o.ElementFromHandle(ByVal h)
Dim iCnd As IUIAutomationCondition
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")

Dim Button As IUIAutomationElement
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
Dim InvokePattern As IUIAutomationInvokePattern
Set InvokePattern = Button.GetCurrentPattern(UIA_InvokePatternId)
InvokePattern.Invoke

End Sub

Sub Doodly(ie)
Do
    DoEvents
Loop Until ie.readystate = 4
End Sub

Sub Muddly(ie)
Do While ie.busy
    DoEvents
Loop
End Sub
EN

回答 1

Stack Overflow用户

发布于 2016-06-11 01:30:39

在导航后立即执行此操作时,我没有收到任何错误

第一步是编译它--可能在你来这里之前先试试这个

替换

代码语言:javascript
复制
Dim ie As SHDocVw.InternetExplorer
Set ie = New InternetExplorerMedium

使用

代码语言:javascript
复制
  Dim ie As Object

在此之前

代码语言:javascript
复制
  Set ie = CreateObject("InternetExplorer.Application")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37753630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档