Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old Yesterday, 11:47 AM
Chopper Chopper is offline search for spelling errors under VBA control Windows 10 search for spelling errors under VBA control Office 2019
Novice
search for spelling errors under VBA control
 
Join Date: Dec 2020
Posts: 16
Chopper is on a distinguished road
Default search for spelling errors under VBA control

I have a bunch of text (MS Word - hundreds of pages) that contains LOTS of instances of two adjacent words run together, i.e., the space between them has been omitted (this is OCR text and apparently the product of a rather crappy OCR program). Anyway, i am trying to correct as many of these "glued together pairs' as I can using a programmatic approach. Specifically, I would like to be able to find and select these pairs by searching and selecting them based on Word's ability to "mark" misspellings with the infamous "wavy red line" (WRL). Problem is, I haven't so far been able to discover whatever mysterious magic Microsoft uses to instigate displaying the WRL.



Many MS gurus just tell me it is not possible, but that makes no sense to me; my computer is responding to some sort of stimulus to display the WRL on the screen when a misspelled word is encountered, so it must be marked in some way. Ideas?

I will sort out how to figure the proper place to place the needed space once I am able to find/select the the "glued pair". Any help/comments/information anyone can offer will be muchly appreciated.
Reply With Quote
  #2  
Old Yesterday, 03:43 PM
macropod's Avatar
macropod macropod is offline search for spelling errors under VBA control Windows 10 search for spelling errors under VBA control Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
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

Using VBA to find spelling errors isn't all that difficult. See, for example:
https://www.msofficeforums.com/112057-post7.html
https://www.msofficeforums.com/119847-post14.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old Yesterday, 07:58 PM
Chopper Chopper is offline search for spelling errors under VBA control Windows 10 search for spelling errors under VBA control Office 2019
Novice
search for spelling errors under VBA control
 
Join Date: Dec 2020
Posts: 16
Chopper is on a distinguished road
Default thanks

I appreciate your reply, but I seem to have failed to adequately describe my quest. i am interested in finding misspelled words after Word has already marked them as 'misspelled' (by underlining them with the 'wavy red line' - which means, I guess, that I would search for the 'marker' that triggers the display of the 'wavy red underline'. I do not wish to re-invent any wheels, i.e., do another spell-check after Word has already done one; I simply want, under program (VBA) control, to examine/edit the text that has already been underlined with the 'WRL' . I understand that such a process wouldn't be 100% accurate, but it might whittle a herculean task down to proportions that would reasonably allow for subsequent manual processing.

I hope this makes my situation more clear.

Thanks again for your interest and attention.
Reply With Quote
  #4  
Old Yesterday, 08:02 PM
macropod's Avatar
macropod macropod is offline search for spelling errors under VBA control Windows 10 search for spelling errors under VBA control Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
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

The code in the link I posted doesn't do another spell-check; it simply loops through all the words Word has already marked as spelling errors.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old Today, 05:54 AM
gmaxey gmaxey is offline search for spelling errors under VBA control Windows 10 search for spelling errors under VBA control Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Quote:
Originally Posted by Chopper View Post
I have a bunch of text (MS Word - hundreds of pages) that contains LOTS of instances of two adjacent words run together, i.e., the space between them has been omitted (this is OCR text and apparently the product of a rather crappy OCR program). Anyway, i am trying to correct as many of these "glued together pairs' as I can using a programmatic approach. Specifically, I would like to be able to find and select these pairs by searching and selecting them based on Word's ability to "mark" misspellings with the infamous "wavy red line" (WRL). Problem is, I haven't so far been able to discover whatever mysterious magic Microsoft uses to instigate displaying the WRL.

Many MS gurus just tell me it is not possible, but that makes no sense to me; my computer is responding to some sort of stimulus to display the WRL on the screen when a misspelled word is encountered, so it must be marked in some way. Ideas?

I will sort out how to figure the proper place to place the needed space once I am able to find/select the the "glued pair". Any help/comments/information anyone can offer will be muchly appreciated.


As Paul has already provens, your so called MS gurus are incorrect. Here is an adaptation of code Paul referred you to. It is up to you to decide if you want to define joined and split pairs for processing:



Code:
Sub AutoSpellCorrect()
Dim oDic As Object
Dim oRng As Range, oSuggestions As Variant
Dim arrJoined() As String, arrSplit() As String
Dim lngIndex As Long
  'Here I have defined a short list of Joined/Split word pairs. You could also use an exteranl list e.g., Excel or word table.
  arrJoined = Split("currentedition|happyending|towncounsel", "|")
  arrSplit = Split("current edition|happy ending|town counsel", "|")
  Set oDic = CreateObject("Scripting.Dictionary")
  For lngIndex = 0 To UBound(arrJoined)
    oDic.Add arrJoined(lngIndex), arrSplit(lngIndex)
  Next lngIndex
  For Each oRng In ActiveDocument.Range.SpellingErrors
    With oRng
      If oDic.Exists(oRng.Text) Then
        oRng.Text = oDic(oRng.Text)
      Else
        oRng.Select
        If .GetSpellingSuggestions.Count > 0 Then
          Set oSuggestions = .GetSpellingSuggestions
          oRng.Text = InputBox("Replace this spelling error with ... ", "REPLACEMENT", oSuggestions(1))
        Else
          oRng.Text = InputBox("Replace this spelling error with ... ", "REPLACEMENT", oRng.Text)
        End If
      End If
    End With
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old Today, 07:15 AM
Chopper Chopper is offline search for spelling errors under VBA control Windows 10 search for spelling errors under VBA control Office 2019
Novice
search for spelling errors under VBA control
 
Join Date: Dec 2020
Posts: 16
Chopper is on a distinguished road
Default Thnx

Thanks to both Macropod and Gmaxey for providing a solution. With only minor tweaking your suggestion(s) solved my problem. I am grateful.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
search for spelling errors under VBA control How to auto populate a rich text content control box from a selection in a combo control box CompletelyLost Word VBA 11 04-25-2025 03:44 PM
Toggling control checkboxes to true when a value in a control drop down is selected ccamm Word VBA 4 03-16-2024 06:44 AM
search for spelling errors under VBA control List Spelling Errors jeffreybrown Word VBA 4 03-23-2020 03:43 PM
search for spelling errors under VBA control Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
search for spelling errors under VBA control How to fix "too many spelling errors" bug? Lebber Word 9 04-26-2013 12:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:49 PM.


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