Re: How do I delete all words that are mispelled in a document?
- From: aq4word <aq4word@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Nov 2007 07:25:01 -0800
Thanks Greg for the rapid response. Sorry about the MVB abbreviation of my
own making. (Microsoft Visual Basic).
I don't come back to you lightly. I've been trying for days to batch your
coding for the now 137 X 20K files of around 1,500 words each. (50% of which
have spelling errors or not English).
It works, as is, fine. i.e. open a file and run the macro on the active file
(I've REM'd the two MSG's to stop having to answer the screen messages). That
is, I open a target file manually in Word 2007 and launch the macro. The
macro continues with the then active file which then gets the red underlines
automatically which the macro deletes. However, when I insert a
DOCUMENTS.OPEN statement (to facilitate batching the 137 files for
processing) it simply fails to do the red underlining and deleting. That is,
the macro completes very quickly having done nothing. The modified code is:-
Sub Test()
Dim myErrors As ProofreadingErrors
Dim myErr As Range
Dim i As Long
Documents.Open FileName:="""c:\users\bhep\documents\scrabble75files\English
(UK)001.srb"""
Set myErrors = ActiveDocument.Range.SpellingErrors
If myErrors.Count = 0 Then
REM MsgBox "No spelling errors found."
Else
For i = myErrors.Count To 1 Step -1
REM MsgBox myErrors(i).Text
myErrors(i).Delete
Next i
End If
ActiveDocument.Save
ActiveDocument.Close
End Sub
I can't get my head around looping at the moment so I'll simply include the
above coding 137 times with filenames ....001.srb to ....137.srb if I can get
it working.
Very much appreciate your help so far.
How can I force the spellchecker to activate. i.e. do its thing of red
underlining to allow the deletes to take place?
Best regards
Brian
"Greg Maxey" wrote:
I don't know what MVB is..
You might try:
Sub Test()
Dim myErrors As ProofreadingErrors
Dim myErr As Range
Dim i As Long
Set myErrors = ActiveDocument.Range.SpellingErrors
If myErrors.Count = 0 Then
MsgBox "No spelling errors found."
Else
For i = myErrors.Count To 1 Step -1
MsgBox myErrors(i).Text
myErrors(i).Delete
Next i
End If
End Sub
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
aq4word wrote:
Hi Greg
I know it's a long time since your post below. (I'm using MVB 6.5
with Word 2007. Maybe therein lies the problem).
I'm trying to apply your macro to 75 files containing around 3,000
words each (i.e. sub-files of a Scrabble dictionary, which, thanks to
Doug Robbins, I was successfully able to split) The macro works most
of the time (I'm up to file 31 after several retries). I get
repeatedly the VB error ' Run-time error '4608' Application-defined
or Object-defined error. On clicking 'debug' it points to the 'Next'
statement in your macro as listed below. I'm using exactly that
coding. Would appreciate any 'get-arounds' just to get me through the
75 files. (And of course, thanks for the macro anyway)
Brian
"Greg Maxey" wrote:
You could try running a macro something like this:
Sub Test()
Dim myErrors As ProofreadingErrors
Dim myErr As Range
Set myErrors = ActiveDocument.Range.SpellingErrors
If myErrors.Count = 0 Then
MsgBox "No spelling errors found."
Else
For Each myErr In myErrors
myErr.Delete
Next
End If
End Sub
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Calipboy wrote:
I have a document with 50k words and I would like to delete all the
words that are underlined red or not recognized by the dictionary
automatically. Going one by one is taking much too long!! Anyone
know how?
- Follow-Ups:
- References:
- Re: How do I delete all words that are mispelled in a document?
- From: aq4word
- Re: How do I delete all words that are mispelled in a document?
- From: Greg Maxey
- Re: How do I delete all words that are mispelled in a document?
- Prev by Date: RE: Two styles of numbering on one line
- Next by Date: Re: Word 2007 Header and Footer Style
- Previous by thread: Re: How do I delete all words that are mispelled in a document?
- Next by thread: Re: How do I delete all words that are mispelled in a document?
- Index(es):
Relevant Pages
|