why why why why 
Author Message
 why why why why

This is such a simple request, and I can't get it to work!

I am trying to launch the spell check of a word document
from my VB app.

I started off with the easy:
    If Options.CheckGrammarWithSpelling = True Then
        ActiveDocument.CheckGrammar
    Else
        ActiveDocument.CheckSpelling
    End If

However, this is not acceptable because the .CheckGrammer
or .CheckSpelling will not return control to the
application until the spell check is finished!!  So
basically this will hang my program.

So then I found this bit of code:
WordApp.CommandBars.FindControl(ID:=2).Execute

Now this is what is really pissing me off, this will only
launch the spell check if my last cursor position is on
text.  If I put my cursor on some spaces, or a line break
or something it won't launch the spell check at all.

Does anyone out there know what I can to do launch the
spell check without{*filter*} my program?



Mon, 31 Jan 2005 23:24:50 GMT  
 why why why why

it sounds like you need to manually iterate through the two
collections of proofreading errors.

Aftyer putting spellingcheck into the help system in the VBE, I found
this topic readily enough - the other topics are also of use in this
case (hint hint)

ProofreadingErrors Collection Object

A collection of spelling and grammatical errors for the specified
document or range. There is no ProofreadingError object; instead, each
item in the ProofreadingErrors collection is a Range object that
represents one spelling or grammatical error.

Using the ProofreadingErrors Collection

Use the SpellingErrors or GrammaticalErrors property to return the
ProofreadingErrors collection. The following example counts the
spelling and grammatical errors in the selection and displays the
results in a message box.

Set pr1 = Selection.Range.SpellingErrors
   sc = pr1.Count
Set pr2 = Selection.Range.GrammaticalErrors
   gc = pr2.Count
Msgbox "Spelling errors: " & sc & vbCr _
    & "Grammatical errors: " & gc
Use SpellingErrors(index), where index is the index number, to return
a single spelling error (represented by a Range object). The following
example finds the second spelling error in the selection and then
selects it.

Set myRange = Selection.Range.SpellingErrors(2)
myRange.Select
Use GrammarErrors(index), where index is the index number, to return a
single grammatical error (represented by a Range object). The
following example returns the sentence that contains the first
grammatical error in the selection.

Set myRange = Selection.Range.GrammaticalErrors(1)
Msgbox myRange.Text
Remarks

The Count property for this collection in a document returns the
number of items in the main story only. To count items in other
stories use the collection with the Range object. If all the words in
the document or range are spelled correctly and are grammatically
correct, the Count property for the ProofreadingErrors object returns
0 (zero) and the SpellingChecked and GrammarChecked properties return
True.


went like this:

Quote:
>This is such a simple request, and I can't get it to work!

>I am trying to launch the spell check of a word document
>from my VB app.

>I started off with the easy:
>    If Options.CheckGrammarWithSpelling = True Then
>        ActiveDocument.CheckGrammar
>    Else
>        ActiveDocument.CheckSpelling
>    End If

>However, this is not acceptable because the .CheckGrammer
>or .CheckSpelling will not return control to the
>application until the spell check is finished!!  So
>basically this will hang my program.

>So then I found this bit of code:
>WordApp.CommandBars.FindControl(ID:=2).Execute

>Now this is what is really pissing me off, this will only
>launch the spell check if my last cursor position is on
>text.  If I put my cursor on some spaces, or a line break
>or something it won't launch the spell check at all.

>Does anyone out there know what I can to do launch the
>spell check without{*filter*} my program?

Steve Hudson -- Word Heretic, Sydney, Australia
{*filter*} teacher, trainer, tutor, writer, developer

Word MVP FAQs: http://www.*-*-*.com/
You agree by writing to me personally that any material can be reused publicly unless you explicitly disclaim it. (For List and blog use.)


Tue, 01 Feb 2005 06:25:43 GMT  
 why why why why
Steven,

Thanks for writing back.

Actually what I am trying to do is much easier than what
you describe I think.

All I am trying to do is launch the spell checker.

I am not writing a Macro, but rather an VB program that is
using OLE Automation to work with the Word object model.

So, all I want to do is click the "start spell check"
button from my code.

The code I presented using the commandbars.findcontrol
before works, but only when your cursor is on text (so in
effect that is not acceptable).  Using the CheckSpelling
method locks the program processing at that line until the
spell check has been completed by the user.  This is also
not acceptable!  I'm frustrated that this is such a pain
to do when I would think it would be very easy.

Chris

Quote:
>-----Original Message-----

>it sounds like you need to manually iterate through the
two
>collections of proofreading errors.

>Aftyer putting spellingcheck into the help system in the
VBE, I found
>this topic readily enough - the other topics are also of
use in this
>case (hint hint)

>ProofreadingErrors Collection Object

>A collection of spelling and grammatical errors for the
specified
>document or range. There is no ProofreadingError object;
instead, each
>item in the ProofreadingErrors collection is a Range
object that
>represents one spelling or grammatical error.

>Using the ProofreadingErrors Collection

>Use the SpellingErrors or GrammaticalErrors property to
return the
>ProofreadingErrors collection. The following example
counts the
>spelling and grammatical errors in the selection and
displays the
>results in a message box.

>Set pr1 = Selection.Range.SpellingErrors
>   sc = pr1.Count
>Set pr2 = Selection.Range.GrammaticalErrors
>   gc = pr2.Count
>Msgbox "Spelling errors: " & sc & vbCr _
>    & "Grammatical errors: " & gc
>Use SpellingErrors(index), where index is the index
number, to return
>a single spelling error (represented by a Range object).
The following
>example finds the second spelling error in the selection
and then
>selects it.

>Set myRange = Selection.Range.SpellingErrors(2)
>myRange.Select
>Use GrammarErrors(index), where index is the index
number, to return a
>single grammatical error (represented by a Range object).
The
>following example returns the sentence that contains the
first
>grammatical error in the selection.

>Set myRange = Selection.Range.GrammaticalErrors(1)
>Msgbox myRange.Text
>Remarks

>The Count property for this collection in a document
returns the
>number of items in the main story only. To count items in
other
>stories use the collection with the Range object. If all
the words in
>the document or range are spelled correctly and are
grammatically
>correct, the Count property for the ProofreadingErrors
object returns
>0 (zero) and the SpellingChecked and GrammarChecked
properties return
>True.


yarn that
>went like this:

>>This is such a simple request, and I can't get it to
work!

>>I am trying to launch the spell check of a word document
>>from my VB app.

>>I started off with the easy:
>>    If Options.CheckGrammarWithSpelling = True Then
>>        ActiveDocument.CheckGrammar
>>    Else
>>        ActiveDocument.CheckSpelling
>>    End If

>>However, this is not acceptable because
the .CheckGrammer
>>or .CheckSpelling will not return control to the
>>application until the spell check is finished!!  So
>>basically this will hang my program.

>>So then I found this bit of code:
>>WordApp.CommandBars.FindControl(ID:=2).Execute

>>Now this is what is really pissing me off, this will
only
>>launch the spell check if my last cursor position is on
>>text.  If I put my cursor on some spaces, or a line
break
>>or something it won't launch the spell check at all.

>>Does anyone out there know what I can to do launch the
>>spell check without{*filter*} my program?

>Steve Hudson -- Word Heretic, Sydney, Australia
>{*filter*} teacher, trainer, tutor, writer, developer


http://www.*-*-*.com/
Quote:
>Word MVP FAQs: http://www.*-*-*.com/
>You agree by writing to me personally that any material

can be reused publicly unless you explicitly disclaim it.
(For List and blog use.)

- Show quoted text -

Quote:
>.



Wed, 02 Feb 2005 04:18:32 GMT  
 why why why why

ActiveDocument.CheckSpelling

Steve Hudson -- Word Heretic, Sydney, Australia
{*filter*} teacher, trainer, tutor, writer, developer

Word MVP FAQs: http://www.*-*-*.com/
You agree by writing to me personally that any material can be reused publicly unless you explicitly disclaim it. (For List and blog use.)



Wed, 02 Feb 2005 09:53:46 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Why why why why?

2. Why Why Why

3. ActiveX wont deploy to Win 2K - why, Why WHY

4. VB6 ListView: Why oh why oh why...

5. Why, Why, Why!!!!!!!!!!!

6. !Excel/VB: why why why?

7. Why,Why,Why are javabeans completely ignored?

8. VB6 ListView: Why oh why oh why...

9. Why -- Oh Why !!!!!!!!

10. Why oh why doesn't this work?

11. DELPHI - why oh why Pascal?

12. Why Microsoft, why'd ya do it?

 

 
Powered by phpBB® Forum Software