title: xlwings Workbook() call returns AttributeError: Open.Application
body: <p>Hope you can help me out, first question I ask myself but I am always impressed by the professional answers I find here!</p>
  
  <p>I am using xlwings to both read and write data from .xls files. I am not a seasoned programmer, and I make mistakes. From time to time, this means rebooting processes, Python and what-not. </p>
  
  <p>Every now and again, I would get the following <code>AttributeError</code> upon calling <code>Workbook()</code>. The real problem is not that I don't have a clue what is happening (I tried reading the modules the error diagnostics reference to, but they are written on a level of Python that is beyond my skills), but that restarting and even rebooting(!) my laptop don't (always) solve the problem.</p>
  
  <p>I wish I could give some clues as to what is happening, but it appears to be a randomly occurring problem and right now, three reboots and several restarts didn't fix it. Google can't help either. I must have run my program a hundred times by now and it wasn't always a problem! The error message, upon simply calling <code>Workbook()</code>:</p>
  
  <pre><code>wb = Workbook()
  
  Traceback (most recent call last):
  
  File "&lt;ipython-input-22-4a3c36eb9bf9&gt;", line 1, in &lt;module&gt;
  wb = Workbook()
  
  File "C:\Program Files\Anaconda\lib\site-packages\xlwings\main.py", line 141, in __init__
  self.xl_app, self.xl_workbook = xlplatform.new_workbook()
  
  File "C:\Program Files\Anaconda\lib\site-packages\xlwings\_xlwindows.py", line 104, in new_workbook
  xl_app = _get_latest_app()
  
  File "C:\Program Files\Anaconda\lib\site-packages\xlwings\_xlwindows.py", line 88, in _get_latest_app
  return xl_workbook_current.Application
  
  File "C:\Program Files\Anaconda\lib\site-packages\win32com\client\dynamic.py", line 522, in __getattr__
  raise AttributeError("%s.%s" % (self._username_, attr))
  
  AttributeError: Open.Application
  </code></pre>
  
  <p>And as a follow up, the piece of code from 'dyamic.py' raising the error:</p>
  
  <pre><code>[...]
  # If we are still here, and have a retEntry, get the OLE item
      if not retEntry is None:
          invoke_type = _GetDescInvokeType(retEntry, pythoncom.INVOKE_PROPERTYGET)
          debug_attr_print("Getting property Id 0x%x from OLE object" % retEntry.dispid)
          try:
              ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
          except pythoncom.com_error, details:
              if details.hresult in ERRORS_BAD_CONTEXT:
                  # May be a method.
                  self._olerepr_.mapFuncs[attr] = retEntry
                  return self._make_method_(attr)
              raise
          debug_attr_print("OLE returned ", ret)
          return self._get_good_object_(ret)
  
      # no where else to look.
      raise AttributeError("%s.%s" % (self._username_, attr))
  </code></pre>
  
  <p>As I mentioned before, the last bit it too much for me :P</p>
  
  <p>I guessed some lingering Excel.exe (or similar) process was interfering with the script after I closed some random window due to some random error, but I cant find one in the task manager. Also, this is the kind of thing a reboot should fix, right?! I also upgraded to xlwings .34 (latest version, as of now).</p>
  
  <p>Windows 8.1 64 bit, Python 2.7 (Anaconda distribution, Spyder IDE), Excel 2013.</p>
  
  <p>Any help is very much appreciated, of course!</p>
  
  <p>Thanks a lot, kind regards,</p>
  
  <p>Gordon.</p>
  
  <p>EDIT:</p>
  
  <p>Following advice given in the comments, I can now report that even at times when <code>wb = Workbook()</code> fails, <code>from win32com.client import dynamic</code> followed by <code>dynamic.Dispatch('Excel.Application')</code> returns <code>&lt;COMObject Excel.Application&gt;</code>.</p>
  
  <p>Hope it helps!</p>