Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-02-2023, 01:40 PM
NitroPress NitroPress is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2016
Novice
Display Navigation and Styles Panes in 365/2021
 
Join Date: Nov 2019
Posts: 22
NitroPress is on a distinguished road
Default Display Navigation and Styles Panes in 365/2021

Okay, I am being forced at gunpoint (==contract paycheck) to use Word 365. My macro, as above, doesn't work, and although I've searched, no one seems to have wanted a sticky Styles pane since about 2014.




Can anyone provide a current macro that will open Nav and Styles, and preferably allow a width setting for each, under 365?


(ETA: Not sure if it's me or 365, but I can't record any form of this macro that would either work or point me to the right VBA elements. I just get an empty macro frame.)



Thx...!

Last edited by NitroPress; 06-02-2023 at 06:05 PM.
Reply With Quote
  #2  
Old 06-02-2023, 06:34 PM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Since this is a new topic, I moved it into its own thread to get the best answers.


I've been trying to do this, futilely, since Word 2019, at least. I had a macro that worked in Word 2013 but does not now. It may have been broken in Word 2016 but I do not remember when I noticed. Here is my Add-In, it still has the code in it for the Styles Pane width but I've disabled that.

Navigation Pane Settings at Word Startup

Last edited by Charles Kenyon; 06-03-2023 at 12:24 PM.
Reply With Quote
  #3  
Old 06-03-2023, 08:17 AM
NitroPress NitroPress is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2016
Novice
Display Navigation and Styles Panes in 365/2021
 
Join Date: Nov 2019
Posts: 22
NitroPress is on a distinguished road
Default

Thanks for the attention to this.


At least that explains why there aren't previous/canned solutions out there for search. Even with my very low regard for what MS has done to Office in the last few revs, I am boggled that this very useful functionality would be removed, even at a low VBA level.


In most of my contracts, I reshape Word docs or libraries around style-based maintenance, and a key element is to force users to open and see the Styles list, so that they can begin to understand its purpose and usefulness. But if it's a manual step, they won't do it... and the ribbon Styles block is massively useless marketing decoration at best.


Sigh. Thanks, though.
Reply With Quote
  #4  
Old 06-03-2023, 08:52 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I share your view of the [Quick] Styles Gallery. It, too, has been degraded by the "New Experience" view. New Experience/Visual Refresh Preview - Microsoft Office - Offic e 365 - Turning it On and Off I suspect that some of the developers at Microsoft do not understand the utility of styles.


The Quick Styles and Quick Style Sets can be very useful. [Quick] Style Sets and Word Themes in Microsoft Word.
Reply With Quote
  #5  
Old 06-03-2023, 09:40 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

The following command works in Word 2010 but not in Word 365/2021.
Code:
application.commandbars("Styles").visible = True
I know that I posted in UserVoice about this some time ago.

Giving Feedback on Microsoft Word or other Microsoft Products

I just filed a new one and you are welcome to vote and comment on it.
Quote:
The vba command:
application.commandbars("Styles").visible = True
worked fine through Word 2013, at least, and now throws an error. Runtime error -21474672259 (80004005) Unspecified error
It can also show error Method 'Visible' of object 'CommandBar' failed. -21474672259 (80004005)

This is to force display of the Styles Pane in Word.

? application.commandbars("Styles").visible in the immediate window will report True or False
? application.commandbars("Styles").position will give a position

The Visible Property can be changed with other commandbars.

This is a bug and should be fixed
Community
Reply With Quote
  #6  
Old 06-03-2023, 11:18 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Although I continue to consider this a bug, Application.TaskPanes(wdTaskPanesFormatting).Visib le is a workaround.
That changes the Styles Pane visible property. Positioning must still be done using the CommandBars.
Reply With Quote
  #7  
Old 06-03-2023, 12:40 PM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

My Add-In at
Navigation Pane Settings at Word Startup does have code to display the Styles Pane but not change the width of that pane.

The Add-In is to let a user set preferences for all documents.


Again Application.TaskPanes(wdTaskPanesFormatting).Visib le = True will display the Styles Pane.

If you add the following to your templates where you want to force display of the Styles and Navigation Panes it should work:

Code:
Sub AutoNew()
    ' Charles Kenyon 2023-06-03
     ' Display Navigation Pane and Styles Pane upon creation of new document based on this template
    ' https://www.msofficeforums.com/175437-post7.html
    '
     With Application.CommandBars("Navigation")
        .Width = 250 ' set to whatevery you want - the default seems wide at 400
        .Visible = True
        .Position = msoBarLeft
    End With
    Application.TaskPanes(wdTaskPaneFormatting).Visible = True
    Application.CommandBars("Styles").Position = msoBarRight
End Sub
Code:
Sub AutoOpen()
    Application.Run AutoNew
End Sub
In a macro-enabled document where you want this to happen that is not attached to the template, you would need:

Code:
Sub AutoOpen()
    ' Charles Kenyon 2023-06-03
    ' Display Navigation Pane and Styles Pane upon opening this document
    With Application.CommandBars("Navigation")
        .Width = 250 ' set to whatevery you want - the default seems wide at 400
        .Visible = True
        .Position = msoBarLeft
    End With
    Application.TaskPanes(wdTaskPaneFormatting).Visible = True
    Application.CommandBars("Styles").Position = msoBarRight
  End Sub
Keep it mind that there is no way you can force another user to let your macros run.


AFAIK, there is currently no way to change the width of the Styles Pane using vba. I believe this changed with Word 2013. The TaskPanes collection does not have width and Word does not pay any attention to it in CommandBars("Styles").Width.

Last edited by Charles Kenyon; 06-04-2023 at 06:46 PM.
Reply With Quote
  #8  
Old 06-05-2023, 01:37 AM
Guessed's Avatar
Guessed Guessed is offline Display Navigation and Styles Panes in 365/2021 Windows 10 Display Navigation and Styles Panes in 365/2021 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This appears to work on my Word 2016 and 365 machines
Code:
    With Application.CommandBars("Navigation")
        .Width = 300 ' set to whatever you want - the default seems wide at 400
        .Visible = True
        .Position = msoBarLeft
    End With
    'Application.TaskPanes(wdTaskPaneFormatting).Visible = True
    With Application.CommandBars("Styles")
      .Visible = True
      .Position = msoBarRight
      .Width = 600
    End With
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 06-05-2023, 05:22 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by Guessed View Post
This appears to work on my Word 2016 and 365 machines
Code:
    With Application.CommandBars("Navigation")
        .Width = 300 ' set to whatever you want - the default seems wide at 400
        .Visible = True
        .Position = msoBarLeft
    End With
    'Application.TaskPanes(wdTaskPaneFormatting).Visible = True
    With Application.CommandBars("Styles")
      .Visible = True
      .Position = msoBarRight
      .Width = 600
    End With

I wish it would on mine!




If I comment out the line with visible, it will run but the Styles Pane is not visible. With the TaskPanes line, it will become visible, however the .Width property is not applied.


When I try it in Safe Mode on 365, it works, sort of!
It halts on the first line. If I display and then hide the Navigation and Styles Panes, it runs and works.
If I display and then hide only the Navigation Pane, it halts on the Styles CommandBar.
Time for some debugging!
Reply With Quote
  #10  
Old 06-05-2023, 05:36 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I do not know what happened, but now the Width property can be set in the Styles pane under CommandBars! This is not in safe mode.
Reply With Quote
  #11  
Old 06-05-2023, 05:41 AM
Guessed's Avatar
Guessed Guessed is offline Display Navigation and Styles Panes in 365/2021 Windows 10 Display Navigation and Styles Panes in 365/2021 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I did get an error initially on 365 but then it worked.

I think if you add an
On Error Resume Next

and then re-enable the TaskPanes line then I expect either one or both will work and if it errors then the second one gets it done anyway.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #12  
Old 06-05-2023, 06:02 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

If I run the code when Word starts, with neither the Navigation Pane nor the Styles Pane having been visible, I get a problem with visible on the CommandBars("Styles").Visible setting.




Note, it does not choke on the Navigation Pane even though it did in Safe mode!


Currently, on my 365 machine, without safe mode, the following runs fine when called but does not run automatically even when named AutoNew in the Normal template:


Code:
  Sub AutoNewStylesNavPane()
      ' Charles Kenyon 2023-06-03
      ' Display Navigation Pane and Styles Pane upon creation of new document based on this template - rename to AutoNew
      ' https://www.msofficeforums.com/175437-post7.html
      '
      With Application.CommandBars("Navigation")
          .Width = 250 ' set to whatevery you want - the default seems wide at 400
          .Visible = True
          .Position = msoBarLeft  ' anchors to left side
      End With
      Application.TaskPanes(wdTaskPaneFormatting).Visible = True ' CommandBars("Styles").Visible will throw an error
      With Application.CommandBars("Styles")
          .Visible = True
          .Position = msoBarRight ' anchors to right side
          .Width = 300 ' sets width
      End With
  End Sub
Without the TaskPanes statement, it throws an error for the visible property for Styles in CommandBars.


I will be exploring whether Document_New will work instead of AutoNew.
Reply With Quote
  #13  
Old 06-05-2023, 06:14 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

When in the Document_New procedure in ThisDocument of Normal.dotm, it does not run. If the Navigation Pane was closed when Word was closed, then it does not activate the Navigation Pane. It does not activate the Styles Pane upon Word startup.

When a new document is created with Word open, it runs showing both panes and adjusting the width as set in the macro.

If in the Document_Open procedure in ThisDocument in Normal.dotm, it has no effect on Word's startup status for either pane. When a document or template is opened from Windows explorer, it has no effect. When a document is opened using File > Open from within Word, it runs.

Curiouser and curiouser! perplex.jpg


@NitroPress
I suspect you will need to have Word already open to have the macros I gave earlier work for you. Warn your users!
Reply With Quote
  #14  
Old 06-05-2023, 07:26 AM
Charles Kenyon Charles Kenyon is offline Display Navigation and Styles Panes in 365/2021 Windows 11 Display Navigation and Styles Panes in 365/2021 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by Guessed View Post
I did get an error initially on 365 but then it worked.

I think if you add an
On Error Resume Next

and then re-enable the TaskPanes line then I expect either one or both will work and if it errors then the second one gets it done anyway.

Andrew,
Thank you for the suggestion.


SpeakEasy, in Eileen's Lounge, suggested:
ActiveDocument.CommandBars.ExecuteMso "StylesPane"


Nothing with the Styles Pane will work in AutoExec because there is no document open and Word won't display the Styles Pane without an open document. Once a document is open and the StylesPane has been activated in some manner, apparently both visible and width work.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Styles display changed - just an alert Charles Kenyon Word 2 11-22-2021 03:04 PM
Unable to connect Styles to the Navigation column. Balliol Word 5 08-04-2019 04:25 AM
Using the Navigation Pane with modified styles susandickerson Word 3 07-10-2014 08:35 PM
How to Customize Outlook Panes Steve_B Outlook 0 07-08-2014 09:05 AM
Can't Display "Recently Used Styles" in Styles Pane mwildem Word 2 05-23-2012 01:42 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft