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

后端 未结 3 805
自闭症患者
自闭症患者 2020-12-21 09:10

I am struggling to get this done since months, how to code VBA to open internet explorer in new session i have an application with many logins i need to open them simultane

相关标签:
3条回答
  • 2020-12-21 09:51

    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
    
    0 讨论(0)
  • 2020-12-21 09:55

    This answer works for me after changing:

    Dim IE As InternetExplorer
    

    to

    Dim IE As Object
    
    0 讨论(0)
  • 2020-12-21 10:02

    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
    
    0 讨论(0)
提交回复
热议问题