title: CreateObject function for "Shell.Application" vs "InternetExplorer.Application"
body: <p>In an answer to this post <a href="http://www.mrexcel.com/forum/excel-questions/553580-visual-basic-applications-macro-already-open-ie-window.html" rel="nofollow noreferrer">VBA Macro For Already Open IE Window</a> <code>CreateObject()</code> is used twice, once with "Shell.Application" and another time with "InternetExplorer.Application".</p>
  
  <p>The first time it is used to reference an already open or already active window.</p>
  
  <p>The second time it is used to create a new browser window.</p>
  
  <pre><code>Sub GetIE_LateBinding()
  
      Dim IE As Object
  
      With CreateObject("Shell.Application").Windows
  
          If .Count &gt; 0 Then
              ' Get IE
              Set IE = .Item(0) ' or .Item(.Count - 1)
          Else
              ' Create IE
              Set IE = CreateObject("InternetExplorer.Application")
              IE.Visible = True
          End If
  
          IE.Navigate "http://support.microsoft.com/kb/q176792/"
  
          Set IE = Nothing
  
      End With
  
  End Sub
  </code></pre>
  
  <p>I tried the following code. It results in a new IE window each time even when there is already an instance open.</p>
  
  <pre><code>Public Sub Trial()
      Dim IE As Object
      Set IE = CreateObject("InternetExplorer.Application")
      IE.Visible = True
  End Sub
  </code></pre>
  
  <p>I can understand the behavior of "InternetExplorer.Application" - <strong>creating new IE application instance</strong> each time hence new window. But "Shell.Application" seems to <strong>fetch already open shell application instance</strong> and hence, we are able to browse the already open IE windows. Seems a bit confusing. What am I missing?</p>
  
  <p>Note: I am guessing something related to class_initialize() for "Shell.Application".</p>