Create Tabbed Dialogs

Tabbed dialog boxes are common in Excel. They break complex dialogs into multiple pages that replace each other as the user clicks on the different tabs. The Options dialog is a good example of a tabbed dialog.

The Toolbox includes two tabbed controls: TabStrip and MultiPage. The main difference between the two controls is that the MultiPage control provides paged containers for other controls. When a user clicks one of the tabs, that page automatically replaces the current page. With the TabStrip control, you have to create your own containers (usually a Frame control) and set the Visible property of that container to show or hide pages. In short, use the MultiPage to quickly create a tabbed dialog; use the TabStrip when you want to control the contents of pages programmatically.

To see how tabbed dialogs work, follow these steps based on the earlier Stock History sample:

  1. In the Visual Basic Editor, choose Insert → UserForm to create a new form.

  2. Click and drag a MultiPage control onto the form.

  3. Open the original Stock History form, select all the controls (Ctrl-A) and copy them (Ctrl-C). Select the MultiPage control and paste (Ctrl-V) the controls onto it.

  4. Copy and paste the code from the frmStockHistory class to the frmStockHistory2 class.

  5. Click the Page1 tab on the MultiPage control and set its Caption to History.

  6. Click the Page2 tab on the MultiPage control and set its Caption to Options. Then add the controls shown in Figure 20-12 with the settings listed in ...

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.