Results 1 to 7 of 7

Thread: Macro to change all styles to a specific language

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location
    Paul,

    Here at least your code needs error handling:

    Sub ChangeStyle()
        Dim oDoc As Document, oSty As Style
        Set oDoc = ActiveDocument.AttachedTemplate.OpenAsDocument
        With oDoc
            For Each oSty In .Styles
                On Error GoTo Err_Handler
                oSty.LanguageID = wdEnglishUS
                Err_ReEntry:
            Next
            .Close SaveChanges:=wdSaveChanges
        End With
        ActiveDocument.UpdateStyles
        Exit Sub
        Err_Handler:
        Resume Err_ReEntry
    End Sub
    Last edited by Aussiebear; 01-26-2025 at 11:41 AM.
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •