gpt4 book ai didi

internet-explorer - 在 Visual Basic 中将焦点设置为 Internet Explorer 对象

转载 作者:行者123 更新时间:2023-12-05 00:34:01 26 4
gpt4 key购买 nike

有人知道如何使用 Visual Basic 将焦点设置到 IE 对象上吗?我试过 myieobject.SetFocus ,但是编译器错误地显示了这条语句。

最佳答案

我需要一个我的电子表格在执行一个功能后“设置焦点”到 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

关于internet-explorer - 在 Visual Basic 中将焦点设置为 Internet Explorer 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11196968/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com