#1
|
|||
|
|||
How to force Word to use the right dictionary?
Hi the forum
In a VBA routine, I highlight spelling mistakes in yellow Code:
For Each rngSpellError In ActiveDocument. SpellingErrors rngSpellError. HighlightColorIndex = wdYellow Next rngSpellError Example Greetings to someone: Jemanden begrüße I greet you: Ich grüße Sie Good tomorrow Guten Morgen! (bis Mittag) Good afternoon Guten Tag (zwischen 12:00 und 18:00 Uhr) the left colomn is marked as written in German. Could a member of this forum advise me to force, in VBA, Word to refer to the right dictionary and not mark a correctly written words as wrong? Thank you in advance GiHem |
#2
|
|||
|
|||
Have you applied the correct proofing language to the words in question? If not, how can you expect Word to know which language to use?
|
#3
|
|||
|
|||
Hi gmaxey,
Thank you for your response. I work mainly in Dutch and German; the respective dictionaries of which are available. The "detect language automatically" checkbox is checked. Isn't that enough, or do I need to specify the language of each word manually? GiHem |
#4
|
||||
|
||||
Detect language automatically is notoriously unreliable and should be switched off. Every character in a document can have its own proofing language attribute, so ensure that the words you want to check have the appropriate proofing language applied. This is best achieved with paragraph and/or character styles.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
Second Graham's advice.
I applied German language to your German words, ran your macro and it seemed to work as intended. |
#6
|
|||
|
|||
Hi gmayor,
Thank you for your interesting answer. I had for a long time noticed that automatic language detection was not 100% reliable. Even when creating a style (linked paragraph and character) dedicated to a language (in my case, German), the result is not 100% guaranteed. Manual intervention is therefore still required. GiHem |
#7
|
|||
|
|||
Hi gmaxey,
Thanks for the answer. The code works fine if MS Word detects the spelling errors. A simple test: copy an article from a German newspaper into an MS Word document. There should be no mistakes. Select the text; change it in lower case and then in sentence case. You will notice that, sometimes, MS Word does not find errors when all the nouns are misspelled. GiHem |
#8
|
|||
|
|||
I have a practical supplementary question: how do I apply the code from the original thread to a selected portion of text and not to the entire document?
Thank you in advance GiHem |
#9
|
|||
|
|||
I have found out how to know if a portion of text is selected.
Code:
Select Case Selection.Type Case wdSelectionNormal MsgBox "there is a selection" Case Else MsgBox "there is no selection" End Select Could a member of this forum help me. Thank you in advance. GiHem |
#10
|
|||
|
|||
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 11/21/2017 Dim rngSpellError For Each rngSpellError In Selection.Range.SpellingErrors rngSpellError.HighlightColorIndex = wdYellow Next rngSpellError lbl_Exit: Exit Sub End Sub |
#11
|
|||
|
|||
Hi gmaxey,
Thank's for your answer and sorry for the late reaction. The proposed solution suits me (almost) completely. The only problem that remains for documents with a lot of pages is the slow execution of the "For"loop. GiHem |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Looking for Dictionary Add-Ins for MS Word | KDL | Word | 0 | 12-01-2015 02:59 PM |
How to force reassociation of .doc files from Word 2003 to Word 2007? | paladin | Word | 3 | 10-22-2014 09:50 PM |
Cannot update dictionary in Word | oilyrag | Word | 0 | 04-05-2014 04:30 AM |
Dictionary customization in Word | nuckollsr | Word | 3 | 01-21-2014 07:43 PM |
Force to select a group of word? | jakekei | Word | 0 | 01-21-2010 04:20 PM |