Error call properties workbook.FileFormat

0
  1. Given I have downloaded a workbook (.xlsx) from the Internet.
  2. And I have installed my VSTO add-in for Excel.
  3. And the add-in subscribed to event "Application.WorkbookOpen".
  4. When I open the workbook.
  5. Then notification pop-ups with "Be careful - files from the Internet... Unless you need to edit, it's safer to stay in Protected View".
  6. When I allow editing the workbook.
  7. Then handler of event "Application.WorkbookOpen" calls property "Workbook.FileFormat",
  8. And it throws an error "System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) in Microsoft.Office.Interop.Excel.WorkbookClass.get_FileFormat()".

Note: If I use Workbook object as dynamic, then "Workbook.FileFormat" returns "-2146826246".

Why did this exception throw? What is "-2146826246"? Has anyone encountered a similar problem?

c#
excel
add-in
excel-interop

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0