title: Excel VBA application.visible immediately set back to True
body: <p>I have set up a new, empty, modeless userform, to fix my problem with the least amount of code involved.</p>
  
  <p>For when the workbook is opened, the following code is executed to hide Excel and show the userform. It's the only code for the workbook.</p>
  
  <pre><code>Private Sub Workbook_Open()
      UserForm1.Show
      If Application.Windows.Count &lt;&gt; 1 Then
          Application.Windows("test.xlsm").Visible = False
      Else
          Application.Visible = False
      End If
  End Sub
  </code></pre>
  
  <p>I have an empty userform with one single button. The only code for this userform is:</p>
  
  <pre><code>Private Sub CommandButton1_Click()
      Application.Windows("test.xlsm").Visible = True
      Application.Visible = True
  Unload Me
  End Sub
  </code></pre>
  
  <p>The last thing is a button on the first worksheet, to start the same process as when the workbook is opened. Its code:</p>
  
  <pre><code>Sub Button1_Click()
      UserForm1.Show
      If Application.Windows.Count &lt;&gt; 1 Then
          Application.Windows("test.xlsm").Visible = False
      Else
          Application.Visible = False
      End If
  End Sub
  </code></pre>
  
  <p>Now my problem:
  When I open the workbook, the userform shows up, but excel and the active window stay visible as well. However, if I click the button on the worksheet, Excel, or the window, are hidden as they should. Also, Excel, not the userform, has focus after loading everything.</p>
  
  <p>The first time I ran this, it worked fine. I suspect changing the ShowModal setting in the editor screwed it up somehow, but that's just me guessing. Anyway, it doesn't work anymore as intended, no matter the modal setting now.</p>
  
  <p>If I just run</p>
  
  <pre><code>Application.Visible = False
  </code></pre>
  
  <p>instead of the "if"-clause, Excel still stays visible and of course so does the active window.</p>
  
  <p>This is driving me nuts.
  What am I missing?</p>
  
  <p>Edit: Link to my test file: <a href="https://www.dropbox.com/s/2jz52956valr0yi/test.xlsm?dl=0" rel="nofollow noreferrer">Test File on my Dropbox</a>
  Might have to start it twice, because when the macros are blocked at startup and only activated after excel has completely loaded, the code works as intended.</p>
  
  <p>Edit: I was able to test this on an excel 2010 pc and there the problem doesn't exist. So it might have something to do with the way newer Office Apps handle stuff.</p>