Description
Represents a single dialog sheet in a workbook. Do not confuse a dialog sheet with the Dialog object, which represents a built-in Microsoft Excel dialog box, or the DialogFrame object, which represents the boundaries of the custom dialog box on a dialog sheet.
Accessors
The DialogSheet object is a member of the DialogSheets collection. The DialogSheets collection contains all the DialogSheet objects in a workbook. Use the Add method to create a new dialog sheet and add it to the collection. To access a single member of the collection, use the DialogSheets method with the index number or name of the dialog sheet as an argument.
The dialog sheet index number represents the position of the dialog sheet on the tab bar of the workbook. DialogSheets(1) is the first (leftmost) dialog sheet in the workbook; DialogSheets(DialogSheets.Count) is the last. All dialog sheets are included in the index count, even if they are hidden. The following example runs dialog sheet one in the active workbook.
DialogSheets(1).Show
The dialog sheet name is shown on the workbook tab for the dialog sheet. Use the Name property to set or return the dialog sheet name. The following example runs the dialog sheet named "Test Dialog."
DialogSheets("test dialog").Show
The DialogSheet object is also a member of the Sheets collection. The Sheets collection contains all of the sheets in the workbook (chart sheets, dialog sheets, modules, and worksheets). To access a single member of the collection, use the Sheets method with the index number or name of the sheet as an argument.
When you write code in an add-in to display a dialog sheet that is also contained in the add-in, you must use the ThisWorkbook property to return a reference to the add-in workbook. You cannot use ActiveWorkbook, and you cannot use Workbooks("workbook name"). This can be confusing, because all three of these methods will work until you create an add-in from your workbook. Once your code is running in an add-in, however, only ThisWorkbook (which returns the workbook where the code is running) can be used to access to add-in workbook.
The following example displays the dialog sheet named "Add-In Dialog" in the running workbook.
ThisWorkbook.DialogSheets("add-in dialog").Show
When a dialog sheet is the active sheet, you can use the ActiveSheet property to refer to it. The following example uses the Activate method to activate dialog sheet one and then runs the dialog sheet.
DialogSheets(1).Activate ActiveSheet.Show
Note that after the example activates the dialog sheet, it uses the ActiveSheet property, not the ActiveDialog property, to return the active dialog sheet. The ActiveSheet property returns the active sheet in the workbook, while the ActiveDialog property returns the topmost running dialog sheet in the workbook. In this example, the dialog sheet is not running and cannot be accessed with the ActiveDialog property.
Properties
Application Property, Creator Property, DefaultButton Property, DialogFrame Property, DisplayAutomaticPageBreaks Property, Focus Property, Index Property, Name Property, Next Property, OnDoubleClick Property, OnSheetActivate Property, OnSheetDeactivate Property, PageSetup Property, Parent Property, Previous Property, ProtectContents Property, ProtectDrawingObjects Property, Visible Property.
Methods
Activate Method, Arcs Method, Buttons Method, ChartObjects Method, CheckBoxes Method, CheckSpelling Method, Copy Method, Delete Method, DrawingObjects Method, Drawings Method, DropDowns Method, EditBoxes Method, Evaluate Method, GroupBoxes Method, GroupObjects Method, Hide Method, Labels Method, Lines Method, ListBoxes Method, Move Method, OLEObjects Method, OptionButtons Method, Ovals Method, Paste Method (DialogSheet or Worksheet Object), PasteSpecial Method (DialogSheet or Worksheet Object), Pictures Method, PrintOut Method, PrintPreview Method, Protect Method, Rectangles Method, SaveAs Method, ScrollBars Method, Select Method, Show Method, Spinners Method, TextBoxes Method, Unprotect Method.