Reputation: 1798
I have used the following VBA and the CommandBars object to display/hide the navigation and styles panes:
Application.CommandBars("Styles").Visible = True
The code for the Styles pane has stopped working. The same code for the Navigation pane continues to work.
How do I turn the Styles and Navigation panes on and off properly? Maybe I was doing it wrong.
I tried recording a macro without success.
I use a toolbar button (alt-ctrl-shift-S) to toggle the styles pane and could write VBA to send those keys explicitly but I would rather do it without keystrokes.
Upvotes: 1
Views: 594
Reputation: 1798
After trying various things over the past week or two, I ended up trying the original code. It's working again. Go figure. I have no idea why it quit or why it started working again. If someone comes across this question in the future, use the snippet posted in the original question.
Upvotes: 0
Reputation: 49455
The use of CommandBars
in Microsoft Office applications has been superseded by the new ribbon component of the Microsoft Office Fluent user interface. For more information, see Overview of the Office Fluent ribbon.
However, some methods like ExecuteMso are still valid and used in cases where there is no object model for a particular command. Works on controls that are built-in buttons, toggleButtons, and splitButtons. On failure, it returns E_InvalidArg for an invalid idMso, and E_Fail for controls that are not enabled or not visible.
Application.CommandBars.ExecuteMso("Copy")
You may try to find the required ID of the built-in control and use the ExecuteMso
to execute it. See Office 2016 Help Files: Office Fluent User Interface Control Identifiers.
Upvotes: 1