This project has moved. For the latest updates, please go here.
/*
   Dialogs in Excel
   taken Example06.cs
*/
public void Example06Main()
{
   // start excel and turn off msg boxes
   Excel.Application excelApplication = new Excel.Application();
   excelApplication.DisplayAlerts = false;
            
   // dont show dialogs with an invisible excel
   excelApplication.Visible = true;

   // add a new workbook
   Excel.Workbook workBook = application.Workbooks.Add();
   Excel.Worksheet workSheet = (Excel.Worksheet)workBook.Worksheets[1];

   // show selected window and display user clicks ok or cancel
   bool returnValue = false;
   
   string dialog = "xlDialogAddinManager"; // change here if you want,
// it's a button selection in example06.cs
switch (dialog) { case "xlDialogAddinManager": returnValue = application.Dialogs[XlBuiltInDialog.xlDialogAddinManager].Show(); break; case "xlDialogFont": returnValue = application.Dialogs[XlBuiltInDialog.xlDialogFont].Show(); break; case "xlDialogEditColor": returnValue = application.Dialogs[XlBuiltInDialog.xlDialogEditColor].Show(); break; case "xlDialogGallery3dBar": returnValue = application.Dialogs[XlBuiltInDialog.xlDialogGallery3dBar].Show(); break; case "xlDialogSearch": returnValue = excelApplication.Dialogs[XlBuiltInDialog.xlDialogSearch].Show(); break; case "xlDialogPrinterSetup": returnValue = application.Dialogs[XlBuiltInDialog.xlDialogPrinterSetup].Show(); break; case "xlDialogFormatNumber": returnValue = application.Dialogs[XlBuiltInDialog.xlDialogFormatNumber].Show(); break; case "xlDialogApplyStyle": returnValue = application.Dialogs[XlBuiltInDialog.xlDialogApplyStyle].Show(); break;
default: throw (new ArgumentOutOfRangeException("Unkown dialog selected.")); } string message = string.Format("The dialog returns {0}.", returnValue); MessageBox.Show(this, message, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information); // close excel and dispose reference application.Quit(); application.Dispose(); }

Last edited May 14, 2012 at 4:51 AM by SebastianDotNet, version 7

Comments

No comments yet.