问题描述
我有一长串条款。超过90%是拼写错误。大部分是中间没有空格的两个字。我注意到MS Word,Excel,Office等都很好地提示正确的拼写。当我运行拼写检查器时,我没有时间确认每一个建议的修正。有一些错误是可以的。如何自动化拼写检查,或者说拼写错误而不提示?我不介意使用微软以外的其他工具,但它的拼写检查器似乎相当不错。我尝试使用一些VBA代码与Excel一起使用,但是我找不到任何以编程方式显示我的主要建议,以便我可以替换拼写错误的术语。
Sub spellcheck()
With Application.SpellingOptions
.SuggestMainOnly = True
.IgnoreCaps = True
。
结束
Cells.CheckSpelling
End Sub
任何帮助都不胜感激。我明白自动纠正的危险。
谢谢,
Steve
第三方拼写检查器,如可能会给您最快的速度&灵活性。但显然,您可以,所以这可能是一种可能性。
鉴于您的特殊情况是由于两个词之间缺少空格,您可能会得到通过Excel的拼写检查器:
Sub test()
Dim str,correction As String
Dim i对于每个str In Array(pancake,sausagebiscuit,oatmeal,largecoffee)
correct = str'
如果.CheckSpelling(str)然后
'已经是一个单词
Else
n = Len(str)
对于i = 1到n
如果.CheckSpelling(Left $(str,i))和.CheckSpelling(Right $(str,n - i))然后
correction = Left $(str,i)& &右$(str,n - i)
End If
Next
End If
Debug.Print str& - >&更正
下一个
结束
结束Sub
输出: / p>
pancake - >煎饼
香肠香肠 - >香肠饼干
燕麦粥 - >燕麦粥
largecoffee - >大咖啡
嗯,早餐....
I have a long list of terms. Over 90% are misspellings. Most of which are two words that have no space in the middle. I noticed that MS Word, Excel, Office, etc. is pretty good at suggesting the correct spelling. When I run the spellchecker, I don't have time to confirm each and every suggested correction. Having some errors are OK.
How can I automate spellcheck, or rather "spellcorrect" without prompting? I don't mind using other tools besides Microsoft, but it's spellchecker seems pretty good. I tried some VBA code to use with Excel, but I can't find anything that will programmatically show me the main suggestion so that I can replace the misspelled term.
Sub spellcheck()
With Application.SpellingOptions
.SuggestMainOnly = True
.IgnoreCaps = True
.
End With
Cells.CheckSpelling
End Sub
Any help is appreciated. And please I understand the danger of auto-correct. The impact of wrongful corrections is minimal.
Thanks, Steve
A third party spell checker, such as aspell might give you the most speed & flexibility. But apparently, you can control the spell checker of Access, so that might be a possibility.
Given your special case of errors being due to lack of space between two words though, you may be able to get by with Excel's spell checker:
Sub test()
Dim str, correction As String
Dim i As Long, n As Long
With Application
For Each str In Array("pancake", "sausagebiscuit", "oatmeal", "largecoffee")
correction = str ' by default leave alone
If .CheckSpelling(str) Then
' already a word
Else
n = Len(str)
For i = 1 To n
If .CheckSpelling(Left$(str, i)) And .CheckSpelling(Right$(str, n - i)) Then
correction = Left$(str, i) & " " & Right$(str, n - i)
End If
Next
End If
Debug.Print str & " -> " & correction
Next
End With
End Sub
Output:
pancake -> pancake
sausagebiscuit -> sausage biscuit
oatmeal -> oatmeal
largecoffee -> large coffee
Mmmm, breakfast....
这篇关于自动更换拼写错误与长期列表的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!