是否有人知道如何将焦点设置到使用Visual Basic的IE对象?我试过myieobject.SetFocus
,但编译器出现这个错误。将焦点设置到Internet Explorer对象在Visual Basic中
3
A
回答
2
我需要我的电子表格来执行功能后,“焦点设置”到Internet Explorer,所以我没有去理会点击它。这是我发现的工作:
Const myPageTitle As String = "Title of my webpage"
Const myPageURL As String = "http://www.mywebpage.com"
Dim myIE As SHDocVw.InternetExplorer
Dim myIE As InternetExplorer
Set myIE = GetOpenIEByTitle(myPageTitle, False)
myIE.visible = false
DoEvents
myIE.visible = true
'for some reason, making the page invisible then visible always ensures it pops up
Function GetOpenIEByTitle(i_Title As String, _
Optional ByVal i_ExactMatch As Boolean = True) As SHDocVw.InternetExplorer
Dim objShellWindows As New SHDocVw.ShellWindows
If i_ExactMatch = False Then i_Title = "*" & i_Title & "*"
'ignore errors when accessing the document property
On Error Resume Next
'loop over all Shell-Windows
For Each GetOpenIEByTitle In objShellWindows
'if the document is of type HTMLDocument, it is an IE window
If TypeName(GetOpenIEByTitle.document) = "HTMLDocument" Then
'check the title
If GetOpenIEByTitle.document.Title Like i_Title Then
'leave, we found the right window
Exit Function
End If
End If
Next
End Function
1
设置.Visible=True
- 如果你在弹出窗口的地方失去了屏幕,你将不得不遍历窗口标题,以激活特定的称号。
Dim objShell As Shell
Dim objIndex As InternetExplorer
Set objShell = New Shell
For Each objIndex In objShell.Windows
If TypeName(objIndex.Document) = "HTMLDocument" Then
If InStr(objIndex.Document.Title, "Stack Overflow") > 0 Then
objIndex.Visible = True
Exit For
End If
End If
Next objIndex
这里就是你可以做的IE对象:MSDN
0
试试这个。通过shell命令打开Internet Explorer,您可以在其中定义焦点(这是重点和小窗口),然后捕获该shell/explorer窗口并将其定义为Internet Explorer对象。也许有比睡眠更好的方法等待。
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub call_IE()
Dim IE As InternetExplorer
Dim htmldoc As HTMLDocument
Set IE = Open_Focused_explorer()
IE.Navigate "google.com"
Set htmldoc = IE.Document
End Sub
Function Open_Focused_explorer() As InternetExplorer
Dim shellWins As ShellWindows
'if windows are 64bit IE is on diferent location
#If Win64 Then
Shell "C:\Program Files (x86)\Internet Explorer\iexplore.exe", vbNormalFocus
#Else
Shell "C:\Program Files\Internet Explorer\iexplore.exe", vbNormalFocus
#End If
'wait until explorer is full loaded
Sleep 4000
On Error Resume Next
'create collection of all explorers
Set shellWins = New ShellWindows
If shellWins.Count > 0 Then
' Get last one
Set Open_Focused_explorer = shellWins.Item(shellWins.Count - 1)
End If
On Error GoTo 0
End Function
相关问题
- 1. 在Internet Explorer中的jQuery焦点
- 2. Visual Basic - 未将对象引用设置为对象的实例
- 3. 在Visual Basic中以编程方式将焦点设置在DataGridView控件
- 4. 使用Visual Basic在Internet Explorer中选择Google搜索结果
- 5. JavaScript:在设置输入元素焦点时,Internet Explorer中的可见性错误
- 6. 未将对象引用设置为对象的实例。 Visual Basic中的VB
- 7. Internet Explorer上的光标焦点问题
- 8. jquery上,焦点和模糊与Internet Explorer
- 9. 将焦点设置到任务栏上
- 10. 如何将焦点设置到DataGridView之外的对象
- 11. asp.net Internet Explorer窗口焦点故障
- 12. 未设置为实例或对象的实例对象。 Visual Basic
- 13. addEventListener触发焦点之前的Internet Explorer焦点?
- 14. 我该如何设置焦点对象
- 15. 如何在Internet Explorer获得焦点时得到通知
- 16. 对象中嵌入无法在Internet Explorer
- 17. 元素/对象在Internet Explorer中为NULL
- 18. 在Internet Explorer 8(IE8)中使用对象?
- 19. 在Internet Explorer中设置元素状态
- 20. 在Internet Explorer中设置textarea选择
- 21. 在Internet Explorer中设置最大宽度
- 22. 未将对象引用设置为对象的实例。 - Visual Basic(Web)
- 23. vba Internet Explorer删除对象
- 24. Internet Explorer 9对象检测
- 25. 对象变量未设置错误,Visual Basic中
- 26. 在Internet Explorer中点击
- 27. 将焦点设置到uifigure窗口
- 28. 在fancybox对话框中设置焦点
- 29. 在UIImagePicker中设置对焦点
- 30. DOM对象只需要两次点击在Internet Explorer中
你是如何与IE的结合?你能告诉我们一些代码吗?另外聚焦IE的目的是什么?你想更新任何领域? –