V
Venkat
Hi,
I have an application which works on Excel as UI. When a workbook is closed
the normal excel displays a message box saying do you want to save Yes, No
or Cancel. If we hit cancel then "Cancellation" of workbook will be done.
Othewise workbook will be closed based on the given value.
Instead of displaying standard Yes, No, Cancel i want to display customised
message box with the same options (Yes,No, Cancel). I am able to display the
message box that i wanted to. But when i hit cancel it does not cancel
workbook close event. Instead it closes irrespective of given input.
I have subscribed to the WorkbookBeforeClose event of Excel applciation. My
method looks like below
excelApp.WorkbookBeforeClose += new
AppEvents_WorkbookBeforeCloseEventHandler(ExcelApplication_WorkbookBeforeClose);
private void ExcelApplication_WorkbookBeforeClose(Workbook Wb, ref bool
Cancel)
{
DialogResult result = GlobalUIFunctions.DisplayWarningMessage("Do you want
to save the project <" + project.Name + ">?", "Close Project",
MessageBoxButtons.YesNoCancel);
if(result == DialogResult.Cancel)
{
Cancel = true; return;
}
}
With the above code my message box will be displayed when user try to close
workbook. If the user selects "Cancel" then it follows to my if loop and
executes every thing perfect. After wards the standard excel dialog box will
be displayed which i want to omit.
Can anyone help me to resolve this?
Cheers,
Srikanth
I have an application which works on Excel as UI. When a workbook is closed
the normal excel displays a message box saying do you want to save Yes, No
or Cancel. If we hit cancel then "Cancellation" of workbook will be done.
Othewise workbook will be closed based on the given value.
Instead of displaying standard Yes, No, Cancel i want to display customised
message box with the same options (Yes,No, Cancel). I am able to display the
message box that i wanted to. But when i hit cancel it does not cancel
workbook close event. Instead it closes irrespective of given input.
I have subscribed to the WorkbookBeforeClose event of Excel applciation. My
method looks like below
excelApp.WorkbookBeforeClose += new
AppEvents_WorkbookBeforeCloseEventHandler(ExcelApplication_WorkbookBeforeClose);
private void ExcelApplication_WorkbookBeforeClose(Workbook Wb, ref bool
Cancel)
{
DialogResult result = GlobalUIFunctions.DisplayWarningMessage("Do you want
to save the project <" + project.Name + ">?", "Close Project",
MessageBoxButtons.YesNoCancel);
if(result == DialogResult.Cancel)
{
Cancel = true; return;
}
}
With the above code my message box will be displayed when user try to close
workbook. If the user selects "Cancel" then it follows to my if loop and
executes every thing perfect. After wards the standard excel dialog box will
be displayed which i want to omit.
Can anyone help me to resolve this?
Cheers,
Srikanth