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.