How to create a ribbon button to show the ‘More Windows’ dialog in Word

The aim

The View menu in Word includes the 'Switch windows' command, but it is limited to showing 9 documents. The 'More windows' dialog is sometimes more convenient, because it shows all open documents. So I want to create a button on a customized ribbon in Microsoft Word to display the 'More windows' dialog.

The problem: using idMso WindowMoreWindowsDialog doesn't work

Microsoft provides a download [Lene Fredborg, 06-Aug-2021: Outdated link to 2010 version replaced with link to 2016 version] that lists all the control IDs for built-in controls on the Word ribbon.

That file lists the command that should show the 'More Windows' dialog: WindowMoreWindowsDialog.

We can use the Word 2010 ‘Customize the Ribbon’ tool to add this command to a custom group on a custom tab, or, we can add it to the Quick Access Toolbar. It's the command listed as 'More Windows'. And it works. When the button is clicked, Word displays the appropriate dialog box.

So I try to add this command by customizing the ribbon in code using

<toggleButton idMso="WindowMoreWindowsDialog" /> <!-- this doesn't work -->

The command is completely ignored. No error is raised. The toggleButton just doesn’t appear.

So, I think, I'll just create a button and have its callback invoke the command directly using .ExecuteMso.

But that doesn't work, either. If I use something like

Application.CommandBars.ExecuteMso("WindowMoreWindowsDialog") ' this doesn't work

I get an unspecified automation error.

That's because .ExecuteMso only works on a control that is both visible and enabled, according to Microsoft's object model documentation. I can't make the control visible, so I can't use .ExecuteMso.

Workaround

There is a workaround: create a custom button on the ribbon and get its click callback to run something like

Application.Dialogs(wdDialogWindowActivate).Show

Related pages

Change the Ribbon in Excel 2007 or Excel 2010 by Excel MVP Ron de Bruin. This is an excellent introduction to customizing the Ribbon. It's geared to Excel, but applies also to Word.