Given I have downloaded a workbook (.xlsx) from the Internet.
And I have installed my VSTO add-in for Excel.
And the add-in subscribed to event "Application.WorkbookOpen".
When I open the workbook.
Then notification pop-ups with "Be careful - files from the Internet... Unless you need to edit, it's safer to stay in Protected View".
When I allow editing the workbook.
Then handler of event "Application.WorkbookOpen" calls property "Workbook.FileFormat",
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?