Dec 23, 2013 at 7:10 PM
Edited Dec 23, 2013 at 7:11 PM
Password prompts as stated in your scenario occur because the underlying Excel workbook is password-protected; this behavior is unrelated to Excel DNA or other API's.
I suggest that once you have a reference to the application and then the desired workbook (and worksheets), to call the Unprotect method that prompts the user to enter the password. I typically wrap such one-time workbook management operations in a single Register
method and then associate it with an event callback into the VSTO object provided by ExcelDnaUtil.Application once my Excel DNA add-in has loaded.
if (Application != null)
Application.WorkbookOpen += new AppEvents_WorkbookOpenEventHandler(excel_WorkbookOpen);
Application.WorkbookBeforeClose += new AppEvents_WorkbookBeforeCloseEventHandler(excel_WorkbookBeforeClose);
Application.WorkbookActivate += new AppEvents_WorkbookActivateEventHandler(excel_WorkbookActivate);
foreach (Workbook workbook in workbooks)
void Register(Workbook workbook)
// register workbook and sheet level callbacks
// check for password
foreach(Worksheet worksheet in workbook.Worksheets)
Then your password-protected workbooks with Excel DNA features (UDF's, macros) should function as desired. Hope this helps.