是否有人知道如何將焦點設置到使用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的目的是什麼?你想更新任何領域? –