![]() |
#1
|
|||
|
|||
![]()
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. |
#2
|
||||
|
||||
![]()
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] |
#3
|
|||
|
|||
![]()
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. |
#4
|
||||
|
||||
![]()
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] |
#5
|
|||
|
|||
![]() Quote:
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 |
#6
|
|||
|
|||
![]()
Thanks to both Macropod and Gmaxey for providing a solution. With only minor tweaking your suggestion(s) solved my problem. I am grateful.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
jeffreybrown | Word VBA | 4 | 03-23-2020 03:43 PM |
![]() |
DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
![]() |
Lebber | Word | 9 | 04-26-2013 12:59 AM |