![]() |
|
#1
|
||||
|
||||
![]()
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] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Spell Check | HondaS600 | Office | 5 | 08-26-2013 01:04 PM |
![]() |
Straitsfan | Word | 1 | 09-16-2012 03:35 PM |
![]() |
mrmagoo | Word | 1 | 08-25-2012 04:55 PM |
![]() |
CommoMP | Word | 5 | 05-30-2011 05:40 PM |
Spell Check | WorkerB | Word | 2 | 11-21-2009 07:22 AM |