View Single Post
 
Old 04-22-2019, 05:03 AM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2016
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 5,878
Charles Kenyon is a name known to allCharles Kenyon is a name known to allCharles Kenyon is a name known to allCharles Kenyon is a name known to allCharles Kenyon is a name known to allCharles Kenyon is a name known to all
Default

Here are the macros. You may need to change the language to suit.


The first one deals with styles.

Code:
Sub StyleEnglishUK()
'   Written 21 March 2018
'   Charles Kenyon
'   Intended to set all styles to EnglishUK, proofing, not automatitically update
'   Language IDs https://docs.microsoft.com/en-us/off...d.wdlanguageid
'
    Dim aStyle As Style
    On Error Resume Next ' Some styles have no language attribute and will give an error
    For Each aStyle In ActiveDocument.Styles
        Select Case aStyle.NameLocal
            Case "TOC 1", "TOC 2", "TOC 3", "TOC 4", "TOC 5", "TOC 6", "TOC 7", "TOC 8", "TOC 9"
                Let aStyle.AutomaticallyUpdate = True
            Case Else
                Let aStyle.AutomaticallyUpdate = False
        End Select
        aStyle.LanguageID = wdEnglishUK
        aStyle.NoProofing = False
    Next 'aStyle
    ActiveDocument.UpdateStylesOnOpen = False ' For information on using this line, see:
'       http://www.shaunakelly.com/word/shar...matchange.html
    On Error GoTo 0
End Sub
Here is the one for the language in the document.
Code:
Sub ProofingLanguageEnglishUKAllStory()    ' based on field updater by Greg Maxey
    ' https://gregmaxey.com/word_tip_pages/word_fields.html
    ' Charles Kenyon 6 November 2018
    ' https://answers.microsoft.com/en-us/...0-5620d0208294
    ' Changes proofing language to English UK in all stories of document
    ' Language IDs https://docs.microsoft.com/en-us/off...d.wdlanguageid
    Dim rngStory As Word.range
    Dim lngValidate As Long ' do not know purpose of this
    Dim oShp As Shape
    lngValidate = ActiveDocument.Sections(1).Headers(1).range.StoryType
    For Each rngStory In ActiveDocument.StoryRanges
      'Iterate through all linked stories
      Do
        On Error Resume Next
        rngStory.LanguageID = wdEnglishUK
        Select Case rngStory.StoryType
          Case 6, 7, 8, 9, 10, 11
            If rngStory.ShapeRange.Count > 0 Then
              For Each oShp In rngStory.ShapeRange
                If oShp.TextFrame.HasText Then
                   oShp.TextFrame.TextRange.LanguageID = wdEnglishUK
                End If
              Next
            End If
          Case Else
            'Do Nothing
        End Select
        On Error GoTo 0
        'Get next linked story (if any)
        Set rngStory = rngStory.NextStoryRange
      Loop Until rngStory Is Nothing
      Next
End Sub
Install/Employ VBA Procedures (Macros) by Greg Maxey, MVP

Instructions for Installing Macros from Forums or Websites by Graham Mayor, MVP
Reply With Quote