(I'm week in English language, so at first excuse me for bad explaining :D )
I open an excel file through my application.
I have an Addd-In in Excel and a button in ribbon for save (exactly such a save action that Save button do) code of Click event of button is here:
Globals.ThisAddIn.Application.ActiveWorkbook.Save();
In my application I assign a method (called WorkbookBeforeSave) to "BeforeSave" event handler of workbook that save workbook manually in my custom directory.
private void WorkbookBeforeSave(bool saveasui, ref bool cancel)
{
_excelApp.EnableEvents = false;//_excelApp is my Excel Application
if (!_excelWorkbook.Saved)//_excelWorkbook is Active Excel Workbook
{
_excelWorkbook.SaveCopyAs(_savedFilePath);//_savedFilePath is my custom directory
_excelWorkbook.Saved = true;
}
cancel = true;
_excelApp.EnableEvents = true;
}
problem is when I click Original Excel Save Button "SaveCopyAs" method works correctly but when click on my custom Save Button "SaveCopyAs" method does not work. (no exception has thrown and all of codes compiled and debugged)