Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-19-2017, 06:48 AM
GiHem GiHem is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2010 64bit
Novice
How to force Word to use the right dictionary?
 
Join Date: Nov 2017
Posts: 10
GiHem is on a distinguished road
Default 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
In a document written in several languages, Word does not always affect the correct dictionary.
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
Reply With Quote
  #2  
Old 11-19-2017, 07:09 AM
gmaxey gmaxey is offline How to force Word to use the right dictionary? Windows 7 32bit How to force Word to use the right dictionary? Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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?
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-19-2017, 09:40 AM
GiHem GiHem is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2010 64bit
Novice
How to force Word to use the right dictionary?
 
Join Date: Nov 2017
Posts: 10
GiHem is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 11-19-2017, 11:58 PM
gmayor's Avatar
gmayor gmayor is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #5  
Old 11-20-2017, 07:16 AM
gmaxey gmaxey is offline How to force Word to use the right dictionary? Windows 7 32bit How to force Word to use the right dictionary? Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Second Graham's advice.

I applied German language to your German words, ran your macro and it seemed to work as intended.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 11-21-2017, 06:07 AM
GiHem GiHem is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2010 64bit
Novice
How to force Word to use the right dictionary?
 
Join Date: Nov 2017
Posts: 10
GiHem is on a distinguished road
Default

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
Reply With Quote
  #7  
Old 11-21-2017, 06:21 AM
GiHem GiHem is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2010 64bit
Novice
How to force Word to use the right dictionary?
 
Join Date: Nov 2017
Posts: 10
GiHem is on a distinguished road
Default

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
Reply With Quote
  #8  
Old 11-21-2017, 07:17 AM
GiHem GiHem is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2010 64bit
Novice
How to force Word to use the right dictionary?
 
Join Date: Nov 2017
Posts: 10
GiHem is on a distinguished road
Default

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
Reply With Quote
  #9  
Old 11-21-2017, 03:02 PM
GiHem GiHem is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2010 64bit
Novice
How to force Word to use the right dictionary?
 
Join Date: Nov 2017
Posts: 10
GiHem is on a distinguished road
Default

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
But I still don't know how to apply a code to this selection and not to the whole document.
Could a member of this forum help me.
Thank you in advance.
GiHem
Reply With Quote
  #10  
Old 11-21-2017, 03:07 PM
gmaxey gmaxey is offline How to force Word to use the right dictionary? Windows 7 32bit How to force Word to use the right dictionary? Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #11  
Old 11-25-2017, 12:39 AM
GiHem GiHem is offline How to force Word to use the right dictionary? Windows 10 How to force Word to use the right dictionary? Office 2010 64bit
Novice
How to force Word to use the right dictionary?
 
Join Date: Nov 2017
Posts: 10
GiHem is on a distinguished road
Default

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
Reply With Quote
Reply

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 Word to use the right dictionary? 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
How to force Word to use the right dictionary? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:01 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft