Class Dialog (Excel VBA)

The class Dialog represents a built-in Microsoft Excel dialog box.


To use a Dialog class variable it first needs to be instantiated, for example

Dim dlg as Dialog
Set dlg = Application.Dialogs(Index:=1)

Dialog class variables can be set using the Dialogs.Item procedure.

For Each

Here is an example of processing the Dialog items in a collection.

Dim dlg As Dialog
For Each dlg In Application.Dialogs
Next dlg


Displays the built-in dialog box, waits for the user to input data, and returns a Boolean value that represents the user's response.

You can use a single dialog box to change many properties at the same time. For example, you can use the Format Cells dialog box to change all the properties of the Font object. For some built-in dialog boxes (the Open dialog box, for example), you can set initial values by using Arg1, Arg2, ..., Arg30. To find the arguments to set, locate the corresponding dialog box constant in Built-In Dialog Box Argument Lists. For example, search for the xlDialogOpen constant to find the arguments for the Open dialog box. For more information about built-in dialog boxes, see the Dialogs collection.

Show (Arg1, Arg2, ..., Arg30)



Arg30 - For built-in dialog boxes only, the initial arguments for the command


Returns a Long value that represents the number of objects in the collection.

Dim lngCount As Long
lngCount = Application.Dialogs.Count


Returns a single object from a collection.

Item (Index)

Index: The name or index number of the object.

Application.Dialogs.Item(xlDialogOpen).Show arg3:=True