This project has moved. For the latest updates, please go here.
' Dialogs in Excel
' taken from Example06.vb
Private Sub Example06Main()

 ' start excel and turn off msg boxes
 Dim excelApplication As New Excel.Application()
 excelApplication.DisplayAlerts = False

 'dont show dialogs with an invisible excel
 excelApplication.Visible = True

 ' add a new workbook
 Dim workBook As Excel.Workbook = excelApplication.Workbooks.Add()
 Dim workSheet As Excel.Worksheet = workBook.Worksheets(1)

 'show selected window and display user clicks ok or cancel
 Dim returnValue As Boolean
 Dim radioSelectButton As RadioButton = GetSelectedRadioButton()

 Select Case radioSelectButton.Text

 Case "xlDialogAddinManager"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogAddinManager).Show()

 Case "xlDialogFont"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogFont).Show()

 Case "xlDialogEditColor"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogEditColor).Show()

 Case "xlDialogGallery3dBar"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogGallery3dBar).Show()

 Case "xlDialogSearch"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogSearch).Show()

 Case "xlDialogPrinterSetup"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogPrinterSetup).Show()

 Case "xlDialogFormatNumber"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogFormatNumber).Show()

 Case "xlDialogApplyStyle"

  returnValue = excelApplication.Dialogs(XlBuiltInDialog.xlDialogApplyStyle).Show()

 End Select

 Dim message As String = String.Format("The dialog returns {0}.", returnValue)
 MessageBox.Show(Me, message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)

 ' close excel and dispose reference

End Sub

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


No comments yet.