How can I return the visible state of task panes in Office applications using VBA?

Jamie Garroch
Jamie Garroch used Ask the Experts™
Office applications have numerous Task Panes. I need to determine which are open/visible. Some are activated via ribbon toggle buttons and/or dialog box launchers while others are activated with buttons.

I can detect those activated with toggle buttons as in this example:

bSelectionPaneOpen = CommandBars.GetPressedMso("SelectionPane")

Open in new window

This doesn;t actually get the state of the task pane but the toggle button associated with it.

Conversely, I cannot do the same for those activated with a button. This example fails because the button isn't a toggle:

bFormatPaneOpen = CommandBars.GetPressedMso("ObjectFormatDialog")

Open in new window

Is there a way to return the visible state of task panes that are activated via buttons?

Word has a TaskPane object but Excel and PowerPoint don't :-(

lTaskPanes = Application.TaskPanes.Count

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Technical Consultant at BrightCarbon
OK, so it appears you need to know the ID of the "CommandBar" that represents the task pane. I couldn't find a definitive list of these but by itterating through the CommandBars collection I found the ones I was interested in:

bPaneVisible = CommandBars("Selection").Visible
bPaneVisible = CommandBars("Comments").Visible
bPaneVisible = CommandBars("Custom Animation").Visible

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial