Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-15-2020, 03:05 PM
shmueldabomb441 shmueldabomb441 is offline Replace all custom dictionary words Windows 10 Replace all custom dictionary words Office 2019
Novice
Replace all custom dictionary words
 
Join Date: Oct 2020
Posts: 2
shmueldabomb441 is on a distinguished road
Default Replace all custom dictionary words


I have added a number of words to the AutoCorrect list of words, to change transliterated Hebrew words to the actual Hebrew words themselves. I would like to make a simple script to iterate through all of the spelling errors in the document and see if any of the words (sanitized, of course) are in the list of exact auto-correct words, and replace them. The farthest I've gotten is discovering the SpellingErrors object. I am not at all familiar with VB, but am with other languages. I would like to have some button to run this script. All help is greatly appreciated.
Reply With Quote
  #2  
Old 10-15-2020, 04:37 PM
macropod's Avatar
macropod macropod is offline Replace all custom dictionary words Windows 10 Replace all custom dictionary words Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Try:
Code:
Sub AutoTransliterate()
Application.ScreenUpdating = False
Dim Rng As Range, oSuggestions As Variant
Const StrDict As String = "CustomDictionary"
For Each Rng In ActiveDocument.Range.SpellingErrors
  With Rng
    If .GetSpellingSuggestions(StrDict).Count > 0 Then
      Set oSuggestions = .GetSpellingSuggestions(StrDict)
      .Text = oSuggestions(1)
    End If
  End With
Next
Application.ScreenUpdating = True
End Sub
Replace 'CustomDictionary' with the file name of the custom dictionary.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-16-2020, 02:03 AM
shmueldabomb441 shmueldabomb441 is offline Replace all custom dictionary words Windows 10 Replace all custom dictionary words Office 2019
Novice
Replace all custom dictionary words
 
Join Date: Oct 2020
Posts: 2
shmueldabomb441 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try:
Code:
Sub AutoTransliterate()
Application.ScreenUpdating = False
Dim Rng As Range, oSuggestions As Variant
Const StrDict As String = "CustomDictionary"
For Each Rng In ActiveDocument.Range.SpellingErrors
  With Rng
    If .GetSpellingSuggestions(StrDict).Count > 0 Then
      Set oSuggestions = .GetSpellingSuggestions(StrDict)
      .Text = oSuggestions(1)
    End If
  End With
Next
Application.ScreenUpdating = True
End Sub
Replace 'CustomDictionary' with the file name of the custom dictionary.
Great answer, thank you so much. I have confidently concluded that the auto correct entries are stored in normal.DOTM. How would the code change based on that?
Reply With Quote
  #4  
Old 10-16-2020, 05:41 AM
macropod's Avatar
macropod macropod is offline Replace all custom dictionary words Windows 10 Replace all custom dictionary words Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Quote:
Originally Posted by shmueldabomb441 View Post
I have confidently concluded that the auto correct entries are stored in normal.DOTM. How would the code change based on that?
You wouldn't. The code is for making corrections based on entries in a Custom Dictionary - which is what the SpellingErrors object ordinarily applies to - and your thread title does say «Replace all custom dictionary words». Accordingly, to use the code I posted, you'd create a Custom Dictionary with the corrections concerned. Of course, that also presupposes Word would be able to recognize which 'correction' goes with what 'error'.

To work with AutoCorrect entries, you might use code like:
Code:
Sub AutoTransliterate()
Application.ScreenUpdating = False
Dim Rng As Range, ACE As AutoCorrectEntry
For Each Rng In ActiveDocument.Range.SpellingErrors
  For Each ACE In AutoCorrect.Entries
    If Rng.Text = ACE.Name Then Rng.Text = ACE.Value
  Next
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
spelling

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
words underlined in red can not be added to the dictionary Jay Bird Word 1 09-19-2020 08:48 PM
Best way to add a large list of words into spell checker: additional custom dictionary Swarup Word 4 07-10-2019 05:08 PM
spelling issue, can't add new words to dictionary Hyper-Energy Bob Word 1 06-18-2016 08:13 PM
Replace all custom dictionary words Custom dictionary to highlight words listed therein only? szachraj Word 2 01-10-2016 05:43 PM
Replace all custom dictionary words Words added to dictionary - what happens when viewed on a different PC cprelude Word 1 02-05-2012 10:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:36 AM.


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