How to code vba to open internet explorer in new session?

夙愿已清 提交于 2019-11-29 15:14:36

Apparently the -nomerge argument will prevent session merging.

Shell("iexplore.exe -nomerge http://www.yoursite.com")

UPDATE

As per your comment, you need to get the IE object. You may be able to work with this:

Dim wshShell
Set wshShell = WScript.CreateObject("WScript.Shell")

wshShell.Run "iexplore -nomerge http://www.google.com"

Dim objShell
Set objShell = CreateObject("Shell.Application")

Dim objShellWindows
Set objShellWindows = objShell.Windows

Dim i
Dim ieObject
For i = 0 To objShellWindows.Count - 1
    If InStr(objShellWindows.Item(i).FullName, "iexplore.exe") <> 0 Then
        Set ieObject = objShellWindows.Item(i)
        If VarType(ieObject.Document) = 8 Then
            MsgBox "Loaded " & ieObject.Document.Title
            Exit For
        End If
    End If
Next

Set ieObject = Nothing
Set objShellWindows = Nothing
Set objShell = Nothing
Set wshShell = Nothing
Melissa D

Using Excel 2010 - This is what I use with a command button. Replace google.com with the website you want to open in another browser.

Private Sub commandname_Click()

'Opens an Explorer with a web site 

Dim IE As InternetExplorer

  Set IE = CreateObject("InternetExplorer.Application")

  IE.navigate ("http://WWW.GOOGLE.COM")

  IE.Visible = True

End Sub
hod

This answer works for me after changing:

Dim IE As InternetExplorer

to

Dim IE As Object
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!