【发布时间】:2016-11-17 14:02:38
【问题描述】:
问题:我目前在关闭“过早”的互联网窗口时遇到了一些问题,该窗口还没有内容。
基本上,如果这个“过早”窗口打开,我的宏无法选择我感兴趣的窗口,但是只要我手动关闭这个“过早”窗口,我就可以正确运行我的代码。 它的来源来自一个小错误,它以某种方式打开它,但除了显示该窗口不会影响其余代码。
测试完成:
Dim Widow As Object, page_foireuse As SHDocVw.InternetExplorer
Dim objShell As Object
Set objShell = CreateObject("Shell.Application")
MsgBox objShell.Windows.Count
' MsgBox objShell.Windows(0).document.Title
' MsgBox objShell.Windows(1).document.Title
' MsgBox objShell.Windows(2).document.Title
' MsgBox objShell.Windows(3).document.Title
' MsgBox objShell.Windows(4).document.Title
' MsgBox objShell.Windows(5).document.Title
' MsgBox objShell.Windows(6).document.Title
'For Each Widow In objShell.Windows
' If Widow.document.Title Is Nothing Then ' this doesn't work
' Set page_foireuse = Widow
' End If
'Next
'
'If objShell.Windows(5).document.Title Is Nothing Then
'End If
Set page_foireuse = objShell.Windows(5)
page_foireuse.Quit
MsgBox objShell.Windows.Count
目前的结果:
- 当我计算shell中的窗口数量时,这个“过早”的窗口也被计算在内
- 当我返回每个计数窗口的位置或标题时,尝试返回“过早”窗口的位置或标题时出现错误
- 我尝试在这端运行的两个循环不起作用
所以我的问题是:如何通过宏关闭这个“过早的”窗口?
【问题讨论】:
-
你得到什么错误,在哪里(哪一行代码)?
-
当我尝试 msgBox 这个页面的标题它不起作用并且错误描述返回 Automation error , unspecified error
标签: windows vba internet-explorer