View Single Post
 
Old 11-24-2018, 06:22 PM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2016
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,465
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

Here is a macro that can be used in your Normal template to set styles.


Code:
Sub StyleSpanish()
'   Written 10 November 2018
'   Charles Kenyon
'   Intended to set all styles to Spanish, proofing, not automatitically update
'
    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
'        aStyle.AutomaticallyUpdate = False ' probably do not want this for TOC styles - future work
        aStyle.LanguageID = wdSpanish
        ' For variations of English, see https://docs.microsoft.com/en-us/office/vba/api/word.wdlanguageid
        aStyle.NoProofing = False   ' also turn on spelling and grammar checking
    Next 'aStyle
    ActiveDocument.UpdateStylesOnOpen = False ' For information on using this line, see:
'       http://www.shaunakelly.com/word/sharing/willmyformatchange.html
    On Error GoTo 0
 End Sub




Here is a macro that can be used to make sure everything currently in a document has the correct proofing language.


Code:

Sub ProofingLanguageSpanishAllStory()    ' based on field updater by Greg Maxey
    ' https://gregmaxey.com/word_tip_pages/word_fields.html
    ' Charles Kenyon 10 November 2018
    ' https://answers.microsoft.com/en-us/msoffice/forum/all/force-all-documents-to-be-edited-in-uk-english/df6d1f8e-5426-49d9-bea0-5620d0208294
    ' Changes proofing language to Spanish in all stories of document
    Dim rngStory As Word.range
    Dim lngValidate As Long ' do not know purpose of this
    Dim oShp As Shape
    Dim oTOC As TableOfContents, oToa As TableOfAuthorities, oTof As TableOfFigures
    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 = wdSpanish
        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 = wdSpanish
                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



Use Replace in Word or the vb Editor to replace “Spanish” with the appropriate constant. I.e., “EnglishUS” for the Constant wdEnglishUS. Here is a list of the language constants:
https://docs.microsoft.com/en-us/office/vba/api/word.wdlanguageid
Reply With Quote