我很努力,因为几个月来完成这件事,如何编写VBA来打开新的会话的Internet Explorer我有许多登录我需要同时打开它们使用自动化的应用程序,我已经使用如何在新会话中编码vba以打开Internet Explorer?
set ie=new InternetExplorer
但它会在旧会话中打开ie,我想为每个登录都打开新会话,请帮助我,我为它搜索了很多内容,但最终没有找到任何解决方案。 这是我的代码
Function GetIE() As InternetExplorer
Dim WScript
Dim objShellWindows
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
Set WScript = CreateObject("WScript.Shell")
Dim ieStarted
ieStarted = False
Dim ieError
ieError = False
Dim seconds
seconds = 0
While (Not ieStarted) And (Not ieError) And (seconds < 30)
If (Not objShellWindows Is Nothing) Then
Dim objIE As InternetExplorer
Dim IE
For Each objIE In objShellWindows
If (Not objIE Is Nothing) Then
If IsObject(objIE.Document) Then
Set IE = objIE.Document
If VarType(IE) = 8 Then
If IE.Title = EmptyTitle Then
If Err.Number = 0 Then
IE.Write LoadingMessage
objIE.navigate Sheet1.Login.Text
ieStarted = True
Set GetIE = objIE
Else
MsgBox ErrorMessage
Err.Clear
ieError = True
Exit For
End If
End If
End If
End If
End If
Set IE = Nothing
Set objIE = Nothing
Next
End If
Application.Wait Now + TimeValue("00:00:1")
seconds = seconds + 1
Wend
Set objShellWindows = Nothing
Set objShell = Nothing
End Function
这段代码即时通讯能够打开浏览器,但可悲的是我的网页是在已经开通请帮助
这是在一个新的会话打开浏览器,但我无法得到即对象,请检查我附上的代码。我需要的功能是“当我们从文件菜单打开新的会话”时 – nothingisimpossible
您可能可以适应[此答案](http://stackoverflow.com/a/7595348/74757)。我会看看我是否可以简化它,如果可以的话,会更新我的帖子。 –
非常感谢你所提供的链接中的代码是完美的工作,除非我需要让我的主页空白才能正常工作:( – nothingisimpossible