View Single Post
 
Old 11-28-2015, 12:19 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,379
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Based on what your link shows, try the following macro.

Since your Spanish definitions are in bold type, the macro first builds a list of all those words and applies Spanish proofing to them. The macro then searches for the same words in italics and applies Spanish proofing to them. A progress report is displayed on the status bar for these processes, but they should run very quickly anyway. That should take care of most words. Finally, the macro checks for italicised spelling errors and prompts the user to say whether the word is Spanish; if so, the macro applies Spanish proofing to those words too.
Code:
Sub SetSpanishLanguage()
Application.ScreenUpdating = False
Dim StrTmp As String, i As Long, Rng As Range
StrTmp = " "
Const StrExcl As String = ".,!¡?¿@#$¢£€%^&*(){}[]:;'~`1234567890-_=+\|“”‘’"""
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = ""
    .Font.Bold = True
    .Format = True
    .Forward = True
    .Wrap = wdFindStop
    .Execute
  End With
  Do While .Find.Found
    If InStr(StrTmp, " " & .Text & " ") = 0 Then
      i = i + 1
      Application.StatusBar = "Adding word " & i & " to Dictionary, please wait."
      StrTmp = StrTmp & .Text & " "
    End If
    .LanguageID = wdSpanish
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
  DoEvents
  For i = 1 To Len(StrExcl)
    StrTmp = Replace(StrTmp, Mid(StrExcl, i, 1), "")
  Next
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Replacement.LanguageID = wdSpanish
    .Font.Italic = True
    .Format = True
    .Forward = True
    .Wrap = wdFindContinue
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    For i = 1 To UBound(Split(StrTmp, " ")) - 1
      Application.StatusBar = "Adding Spanish Proofing to word " & i & ", please wait."
      .Text = Split(StrTmp, " ")(i)
      .Replacement.Text = "^&"
      .Execute Replace:=wdReplaceAll
    Next
  End With
End With
Application.ScreenUpdating = True
With ActiveDocument.Range
  For Each Rng In .SpellingErrors
    With Rng
      If .Font.Italic = True Then
        .Select
        If MsgBox("Is this a Spanish word?", vbYesNo, "Language Checker") = vbYes Then
          .LanguageID = wdSpanish
        End If
      End If
    End With
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote