title: Error when quitting Excel and Logging Off
body: <p>I need some help with Excel VBA (2010 on windows 7).
  What I'm trying to do is close Excel and then shutdown the pc.
  The code I have is:</p>
  
  <pre><code>Declare Function ExitWindowsEx&amp; Lib "User32" (ByVal uFlags As Long, ByVal dwReserved AS Long)
  Global Const EWX_LOGOFF = 0
  Global Const EWX_FORCE = 4
  
  ....Main Code Here ....
  
  Application.DisplayAlerts = False
  Application.Quit
  
  Action = ExitWindows(EWX_LOGOFF or EWX_FORCE, 0)
  </code></pre>
  
  <p>Intermittently I get the following error:</p>
  
  <blockquote>
    <p>Cannot Quit Microsoft Excel</p>
  </blockquote>
  
  <p>The machine still logs off though, which is what I want so it's not a major issue.  I would just like to exit cleanly.  I've kept EWX_FORCE as I don't want to be prompted by windows.
  Any suggestions?</p>