tags:

views:

429

answers:

2

Hi

I create an Excel Workbook solution in Visual Studio 2008. When I build the solution I get a .XLS file and a .DLL (customize assembly).

I can now start up the Excel sheet just by double clicking on the .XLS and there is my sheet functioning with all my C# code.

But in cast of that customize dll unavailable. I start up Excel workbook again and Excel popup message "The customize assembly could not be found or could not be loaded. You can still edit and save the document. Contact your administrator or the auther of this document for further assistance." have Detail and OK Button. If I press OK Button excel workbook still working. How to automatic close or shutdown this workbook?

Thanks

A: 

You can't reliably do this. You need to be able to run code to close the workbook, and if the DLL containing your code can't be found, you can't run code from there to close the workbook. You might be able to hack in a VBA Workbook_Open handler into the same workbook that would check for the presence of your managed code somehow and try to close the workbook if it didn't load correctly, but that assumes you can get the VBA to run, which the default settings on Excel 2007 and higher would prevent (even if the VBA were signed). I also don't know offhand which handler would run first in the presence of both managed code and VBA.

nitzmahone