MS-Excel / General Formatting

Creating a Dialog Launcher

You've probably seen the small button that appears in the lower-right corner of some Ribbon groups. In Word's Home tab, for example, the button appears in the Clipboard, Font, Paragraph, and Styles groups. In each case, clicking the button opens a dialog box. In the Font group, for example, clicking the button opens the Font dialog box.

This button is called a dialog box launcher, and you can add them to your custom Ribbon groups. Your custom dialog box launchers can open any of the application's built-in dialog boxes or a custom dialog box that you've built in the Visual Basic Editor.

You begin with an empty <dialogBoxLauncher> element:

<dialogBoxLauncher>
</dialogBoxLauncher>

Between these elements, you add a single <button> element:

<dialogBoxLauncher>
    <button id="dlLaunchInsertHyperlinkDialog"
	onAction="Module1.dlLaunchInsertHyperlinkDialog_OnAction" />
</dialogBoxLauncher>

Here's the code for the LaunchInsertHyperlinkDialog macro:

Sub dlLaunchInsertHyperlinkDialog_OnAction(ByVal control As IRibbonControl)
    Dialogs(wdDialogInsertHyperlink).Show
End Sub
[Previous] [Contents] [Next]