Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-15-2021, 11:53 AM
JingleBelle JingleBelle is offline Update Heading Styles Linked to List Gallery Windows 10 Update Heading Styles Linked to List Gallery Office 2016
Novice
Update Heading Styles Linked to List Gallery
 
Join Date: Nov 2020
Posts: 26
JingleBelle is on a distinguished road
Default Update Heading Styles Linked to List Gallery

Frequently, I need to update the heading styles in many documents. Instead of opening each file, updating the styles, resaving, etc., I thought I could use Macropod’s recently posted code https://www.msofficeforums.com/word-...es-folder.html to update said styles.

It works beautifully except for Headings 1 through 9, which are linked to a list gallery (Outline Number Gallery). For these, the text of the heading updates as needed; however, the linked list level number does not. I am stumped but hopeful someone, here, will take a look and tell me how to correct the code. Following is my attempt to update just the Heading 1 style. I'm thinking if I can get this code to work correctly, I can use it moving forward to update Headings 2 through 9.

Code:
Sub UpdateFolderStyles()

Application.ScreenUpdating = False
Dim strDocNm As String, strFolder As String, strFile As String
Dim wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
strDocNm = ThisDocument.FullName
While strFile <> ""
  If strFolder & "\" & strFile <> strDocNm Then
    Set wdDoc = Documents.Open(Filename:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
    
    With wdDoc
      .Styles("Heading 1").Font.Name = "Arial"
      .Styles("Heading 1").Font.Size = 14
      
       With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
        .NumberFormat = "%1."
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleArabic
        .NumberPosition = InchesToPoints(0)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = InchesToPoints(0.33)
        .TabPosition = InchesToPoints(0.33)
        .ResetOnHigher = 0
        .StartAt = 1
        With .Font
            .Bold = True
            .Color = wdBlack
            .Size = 14
            .Name = "Arial Bold"
        End With
        .LinkedStyle = "Heading 1"
    End With
      .Close SaveChanges:=True
    End With
  End If
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function

Reply With Quote
 

Tags
all files in folder, list level numbering, styles



Similar Threads
Thread Thread Starter Forum Replies Last Post
Built in Heading Style are actually linked styles. Why? Mr Freeze Word 7 10-10-2019 07:57 AM
Keeping or restoring "Start at" value for heading list after updating styles from a template WordUser789 Word VBA 9 04-15-2019 12:16 AM
how to not add styles to style gallery when pasting text usrqsts Word 9 03-04-2016 11:41 AM
Update Heading Styles Linked to List Gallery Word 2013: My custom table styles disappeared from Gallery sinz54 Word Tables 1 03-13-2015 05:02 PM
Update Heading Styles Linked to List Gallery Heading styles come "unlinked" from Multi-level list levels after save. spthomas Word 3 11-27-2013 03:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:44 AM.


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