Sorting list via spelling errors

R

rob nobel

Hi Brian, I used the following, but sorry I can't help you with it as I'm
fairly new at all this VBA stuff in Word.
Sub DeleteSpellingErrors()
Dim oPara As Paragraph
Dim oSpellingSuggestions As SpellingSuggestions
Set oPara = ActiveDocument.Paragraphs(1)
Do Until oPara.Range.End = ActiveDocument.Range.End
Set oSpellingSuggestions = oPara.Range.GetSpellingSuggestions
If oSpellingSuggestions.SpellingErrorType = wdSpellingNotInDictionary
Then
oPara.Range.Delete
Else
Set oPara = oPara.Next
End If
Application.StatusBar = CStr(Int(100 * _
oPara.Range.End / ActiveDocument.Range.End)) & "% complete"
Loop
End Sub

Good luck,
Rob
 
M

Malcolm Smith

Rob

Love the signature and, touché.

Which leads me onto my next bit; the accent over the words. Yes, some
English words derived from the French do have the accents; "touché" should
have one.

Those words which you have listed all have accents on as we have taken
them directly from the French. And so, with the accents are correctly
spelt as such.

Some words also have the "æ" in some variants of spelling which is
perfectly acceptable.

[Ozzie Rules; a wonderfully mad game in which one uses another player's
kidneys as a stepladder to reach the ball. Also played on an oval
because the first games were played on cricket fields. I have always
wondered what medication they had to give the groundsman...]

Best wishes
- Malc
www.dragondrop.com
 
R

rob nobel

Hi Malcolm,
Can't understand though why your procedure didn't pick them up as when I ran
spell checker again, it did find them as errors as the words in the giant
list did not have the accent above the letters. But never mind about it now
as it's pretty much OK now.
I knew there was a name for that ' thingy. I guess the French need as much
help as they can get even to help them to remember what part of the word
they need to stress!
But I reckon any nation that wants to take over England would need some
help. I notice they've stoped their advances for a few 100 years or so.
Maybe England's lost it's appeal?
And your right about the Oval bit......strange I know. And the
groundsmen......well, they're all great lovers of the game and wouldn't need
medication.
BTW, forgot to mention our success over the Irish in that strange mixed up
version of whatever it's called. Can't wait to thrash you chaps at the
round ball version you play! I think you call it soccer. To me, that's
something you do to your wife if she's misbehaving - you soccer ;)
Regards,
Rob
 
J

JGM

rob nobel said:
Hi Malcolm,
Can't understand though why your procedure didn't pick them up as when I ran
spell checker again, it did find them as errors as the words in the giant
list did not have the accent above the letters. But never mind about it now
as it's pretty much OK now.
I knew there was a name for that ' thingy. I guess the French need as much
help as they can get even to help them to remember what part of the word
they need to stress!

For your information, the "thingy" in French is not for stress usage. Why do
people always seem to think that their way of doing things is the way
everybody does it? Is it a lack of culture awarennes? A lack of
opportunities meeting and exchanging with people from different parts of the
world? Very puzzling... It is not because English is stress-timed that every
other language is stress-timed as well. French, like Finnish, Spanish,
Rumanian, Thai, Hindi, Persian, Serbo-Croat and many other languages is not
stress-timed. It is syllable-timed (the stress pattern is regular,
regardless of the words being used - like in the first syllable of the word,
English, like Russian, has no regular stress pattern as such, the stress
belongs to the word). In French the accents are used to change the vowel
sound, as in "dé" = "day," "è" = the "e" in "bet" but "e" alone = the "a" in
"idea", etc. I guess you can be excused because of the connotation "accent"
has in English. Actually, stress-timed languages are sometimes referred to
as "accentuated" languages...

Still, generally speaking, please, refrain from making derogatory comments
(or at least "jokes" that could easily be misinterpreted as such) about
other cultures when writing in a newsgroup. There are people from all over
the world that read these. After all, you don't want people thinking that
Ozzies are uncouth and uncivilized! But, I guess that from the way you play
your games down under, the damage has already been done. I saw hurling on
the tube a couple of times. Phew. What a game!


G'day!
 
K

Klaus Linke

Hi Rob,

Seems pretty daft of MS to make the spell checking functions take Ranges as
arguments, and not Text.
After all, only the pure text is relevant for the spell checker.

If they had made it work on text, then you could speed up this kind of macro
by reading the document text into a string, and work on that.

But as I said earlier, the VBA access to the dictionaries is so slow that
accessing the document multiple times for each paragraph isn't the
bottleneck, anyway.
(BTW: for the same reason, the type of loop you choose isn't really relevant
here... as long as you don't make a terrible choice like "For i = 1 to
ActiveDocument.Paragraphs.Count")

Regards,
Klaus
 
K

Klaus Linke

Malcolm Smith said:
Ah, but the .Text property is usually part of a Range object, is it not?

By making the Range the argument, you are forced to access the Range.
If you could just specify the text, it could be much faster.

You could use Application.CheckSpelling with Text.

You might be able to speed up the macro by only looking closer
(.SpellingSuggestions) at words that aren't in the main dictionary.

But because of a bug, you can't specify the language.

Bizarrely, it seems to return True ("no errors")
-- for English words in my German version of Word 2002, and
-- for German words in my English version of Word 2003.

I have found no way to influence that. The language of the current
selection, or specifying the language with
WordBasic.ToolsLanguage Language:="English (UK)"
makes no difference.

The main dictionary you can specify has absolutely no consequence, either,
it seems:
Application.CheckSpelling _
(Word:="test", _
MainDictionary:=Languages(wdEnglishUK).ActiveSpellingDictionary, _
IgnoreUppercase:=True)

Makes no sense at all, but it's pretty definitely behaving that way for me.

Regards,
Klaus
 
R

rob nobel

Well Jean-Guy, seems I've trodden on a toe. Not intented, as most said with
tongue in cheek (whatever that may mean), but sorry if I did. My humour
usually ends me up in strife and I agree, the newsgroup is probably not the
place for it due to it's vast audience. Touble is, it's a pleasant change
to get some "harmless" banter from just the normal explanation to a question
posed and, once there, it can become encapsulating so that one forgets that
others are watching.
PS. I agree that hurling is a great game, but the combination of hurling and
Ozzie rules???
Rob
 
M

Malcolm Smith

Klaus

Ah, no sense. Yes, I can't argue with that. I have never been happy with
the way that Word does it's spell checking; even from the front end.

- Malc
 
B

Bob S

Hi Jonathan,

Your little trick for the % in the status bar is so great I had to try it.

I have a project where I have to scan from 200 to 1000 fields in a document,
so I thought this would be perfect to keep the user informed as to the
progress...
Here is the code I first used

'First locate the field...
For i = 1 To TargetDoc.Fields.Count
If Not InStr(TargetDoc.Fields(i).Code.Text, FullTextKey) = 0 Then
TargetTextFound = True
Exit For
End If
Application.StatusBar = Cstr(Int(100 * _
i / TargetDoc.Fields.Count)) & " % of records scanned..."
Next i

It was fine exepct that I kept getting an "Capacity overload" error, as if
the functon could not handle "large" numbers.
For example, when i = 321 and TargetDoc.Fields.Count = 421, that was the
threshold, if I increased I got the error every time.
I tried with raw numbers to make sure:
Cstr(Int(100 * 321 / 421))
still same result.

So, I hate it when the machine foils my plans... I played around witht it
and came up with the following solution:

Application.StatusBar = CLng(CLng(100) * _
CLng(i) / CLng(TargetDoc.Fields.Count)) & " % of records
scanned..."

Why did I get the error message in the first case (CStr..), but not the
second one (CLng...)?

TIA


Very odd; I can see why it would fail at 328 but not at 321...

At 328 it fails because 100 * 328 fails. VBA sees two Integers,
multiplies them, and gets upset because the result isn't an Integer.

You might try this and see whether it works in your case:

Application.StatusBar = Cstr(Int(100.00 * _
i / TargetDoc.Fields.Count)) & " % of records scanned..."

Notice that it is 100.00 to force VBA to use floating point.

Bob S
 
W

Word Heretic

G'day Bob S <[email protected]>,

try using longs instead of ints


Bob S said:
Very odd; I can see why it would fail at 328 but not at 321...

At 328 it fails because 100 * 328 fails. VBA sees two Integers,
multiplies them, and gets upset because the result isn't an Integer.

You might try this and see whether it works in your case:

Application.StatusBar = Cstr(Int(100.00 * _
i / TargetDoc.Fields.Count)) & " % of records scanned..."

Notice that it is 100.00 to force VBA to use floating point.

Bob S

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
W

Word Heretic

G'day Bob S <[email protected]>,

or even better - doubles

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
J

JGM

Thanks Bob,

I understand now that I had overlookd the fact the CInt deals with integers
and that integers in VB have a maximum value..., although the final result
is well below that maximum, the intermediate stage (the multiplication
before the division), as you pointed out, yields a number that is over that
maximum. As Steve said in his reply, to be safe, I should use Double instead
of Long...

Thanks for taking the time...

p.s. You are probably right regarding the 321 vs 328, I remember that when I
wrote that message 2 weeks ago, I was writing it from memory (I did not have
the erroneous code in front of me as I had already solved it by using
Long...) so I must have gotten my numbers wrong a bit!
p.p.s. Why do I need the Clong or Cstr or Cint in the first place? Could I
not just send the equation result to the status bar, as in:
Application.StatusBar = (100 * i ) / TargetDoc.Fields.Count & " % of
records scanned..."

Cheers!
 
J

JGM

Never mind Bob,

I just realized why...
We could end up with a huge quantity of digits after the decimal point...
Well at least, that's my understanding!

Cheers!
 
W

Word Heretic

G'day "JGM" <[email protected]>,

Correct. Just use the Cint outside the fractional calculation part

JGM said:
Never mind Bob,

I just realized why...
We could end up with a huge quantity of digits after the decimal point...
Well at least, that's my understanding!

Cheers!

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top