title: Why are my excel workbooks invisible in Excel 2010?
body: <p>I've been running an excel export function with .xlsx files.  Occasionally when loading an excel file I use the System.Runtime.InteropServices.Marshal.BindToMoniker() method.  When the file in question is <em>not</em> open, but exists, i get the following results:  </p>
  
  <p>Excel will start, but the workbook will not load, and neither will any worksheets.  Excel appears blank.</p>
  
  <p>When opening the file outside of the program that performs the exporting, it loads in exactly the same way.  Excel is open, it says Microsoft Excel at the top of the window, but there are no visible sheets.  Excel looks like there is nothing open at all.    </p>
  
  <p>Going into the options also suggests that there are no workbooks open.  The file definitely has content though, as I can see when I open it in Notepad++ The document has enough detail for me to see that there are sheets in the workbook, but nothign shows up.  </p>
  
  <p>I'm not sure how to prevent this corruption from happening programmatically, or how to fix it.  Any suggestions or thoughts would be appreciated!  </p>
  
  <p>To avoid the problem I never use BindToMoniker on closed Excel files (by checking whether the file is locked or not, if it's unlocked, I just use the open function)</p>
  
  <p>Here is the code that runs when i get this problem.  It will only happen if the file exists and is not open:</p>
  
  <pre><code>    Public Function OpenExcelFile( _
      ByRef pobjExcel As Excel.Application, _
      ByRef pwkbWorkBook As Excel.Workbook, _
      ByVal pstrFileName As String) As Boolean 
  </code></pre>
  
  <p>...</p>
  
  <pre><code>pwkbWorkBook = BindToMoniker(pstrFileName)
              pobjExcel = pwkbWorkBook.Parent
              pobjExcel.Visible = True 'Temp; I use this to see the state of the file
  </code></pre>