View Single Post
 
Old 06-03-2023, 12:40 PM
Charles Kenyon Charles Kenyon is offline Windows 11 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 8,900
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