我正在运行64位excel,我需要打开32位IE,以便java在我导航到的页面上运行(我正在使用某些特定限制进行此操作)。我不能为我的生活弄清楚如何让它工作。
我已经尝试了所有搜索过的代码,但似乎没有任何代码可以帮助我。当我运行下面的代码时,我收到了错误
activex组件无法创建对象“错误:设置 objShellWindows = objShell.Windows
AppURL = "http://www.stackoverflow.com"
AppToRun = "iexplore -nomerge"
AboutBlankTitle = "Blank Page"
LoadingMessage = "Loading stackoverflow..."
ErrorMessage = "An error occurred while loading stackoverflow. Please close the Internet Explorer with Blank Page and try again. If the problem continues please contact IT."
EmptyTitle = ""
'Launch Internet Explorer in a separate process as a minimized window so we don't see the toolbars disappearing
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run AppToRun, 6
Dim objShell
Dim objShellWindows
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
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
Dim IE
'For each IE object
For Each objIE In objShellWindows
If (Not objIE Is Nothing) Then
If IsObject(objIE.Document) Then
Set IE = objIE.Document
'For each IE object that isn't an activex control
If VarType(IE) = 8 Then
If IE.Title = EmptyTitle Then
If Err.Number = 0 Then
IE.Write LoadingMessage
objIE.Toolbar = 0
objIE.StatusBar = 1
objIE.Navigate2 AppURL
ieStarted = True
Else
'To see the full error comment out On Error Resume Next on line 1
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
WScript.sleep 1000
seconds = seconds + 1
Wend
Set objShellWindows = Nothing
Set objShell = Nothing
'Activate the IE window and restore it
success = WshShell.AppActivate(AboutBlankTitle)
If success Then
WshShell.SendKeys "% r" 'restore
End If