PDA

View Full Version : Automatic spell check and formatting



Programmer_n
09-03-2016, 08:30 PM
In word I have come across automatic spellcheck; wherein, it selects the first best word from the auto suggestion.

But it doesn't work for case like this. For instance in the line below any thing is underlined in squiggly blue, on right clicking it gives auto correct suggestion as anything.

To change the overall look of your document, choose new Theme any thing elements on the Page Layout tab.

Is it something to do with formatting inconsistency or do with contextual spell check?

Is it possible to code a program for automatically selecting first best option from auto suggestion for formatting inconsistency and contextual spell check?

gmaxey
09-04-2016, 04:42 PM
Where/how have you come across automatic spellcheck? If that is a feature that you can possibly turn on then I want to make sure it is turned off.

any thing as you used is considered a spelling error (yes contextual) but a spelling error none the less.

You can run through:
Dim oRng As Range
For Each oRng In ActiveDocument.SpellingErrors
oRng.CheckSpelling
Next

To display the dialog, but I don't know how you would automatically select the first suggested spelling which might not be the best or even suitable in all cases.

Programmer_n
09-04-2016, 06:05 PM
Where/how have you come across automatic spellcheck? If that is a feature that you can possibly turn on then I want to make sure it is turned off.

any thing as you used is considered a spelling error (yes contextual) but a spelling error none the less.

You can run through:
Dim oRng As Range
For Each oRng In ActiveDocument.SpellingErrors
oRng.CheckSpelling
Next

To display the dialog, but I don't know how you would automatically select the first suggested spelling which might not be the best or even suitable in all cases.

I understand it might not be the best or suitable in all cases, but I am looking at many cases.From my experience with the type of spelling errors I make, it is almost there.

Application.GetSpellingSuggestions Method replaces the wrongly spelled word with first word.

A snippet of the code I came across in net does this.


For Each wd In ActiveDocument.Words
oldtxt = wd.Text
If Not Application.CheckSpelling(Word:=oldtxt, IgnoreUppercase:=True) Then
Set sugg = Application.GetSpellingSuggestions(oldtxt)
If sugg.Count <> 0 Then
newtxt = Application.GetSpellingSuggestions(oldtxt).Item(1)
If Right(oldtxt, 1) = " " Then addspace = " " Else addspace = ""
wd.Text = newtxt & addspace
End If
End If

But this code replaces only red-underlined words not the blue ones like "any thing".

gmaxey
09-05-2016, 07:46 AM
While:


Dim oRng As Range
For Each oRng In ActiveDocument.SpellingErrors
oRng.CheckSpelling
Next


Triggers the check spelling dialog box with suggestions for things like "I here the dog barking" and "I don't like any thing they offer." GetSpellingSuggestions doesn't not. I suspect that this is just another case where Microsoft has not expended the effort and resources to keep VBA up to date with the application.