Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Spelll check question, Word 2003, Windows XP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alan Stancliff - 08 Mar 2008 05:05 GMT
In Word 2003, is there a way, with VBA code, to run a spell check on
just section 2 of a document?

I have been playing with various versions of ActiveDocument.sections(2),
but somehow, I don't quite seem to be able to figure it out.

Regards,

Alan Stancliff
Graham Mayor - 08 Mar 2008 10:49 GMT
You need something like:

Sub SpellSec2()
Dim Sec2 As Range
   Set Sec2 = ActiveDocument.Sections(2).Range
   With Sec2
       .Select
       #If VBA6 Then
           .NoProofing = False
       #End If
       .LanguageID = wdEnglishUS
       .CheckSpelling
   End With
End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> In Word 2003, is there a way, with VBA code, to run a spell check on
> just section 2 of a document?
[quoted text clipped - 5 lines]
>
> Alan Stancliff
Alan Stancliff - 08 Mar 2008 20:20 GMT
Thanks Graham,

I'm still trying to learn the syntax for VBA.

I tried this little  macro just now, and it skipped running a
spell-check  on section 1 (good), spell-checked section 2 (good), but
also spell-checked section 3. Is there a way to keep it from checking
section 3?

Regards,

Alan Stancliff

*********
> You need something like:
>
[quoted text clipped - 10 lines]
>     End With
> End Sub
Graham Mayor - 09 Mar 2008 09:39 GMT
It only spell checks section 2 in my document?

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Thanks Graham,
>
[quoted text clipped - 24 lines]
>>     End With
>> End Sub
Alan Stancliff - 10 Mar 2008 03:35 GMT
That is odd, Graham. I will check it out again this evening after work.
Perhaps it was just a glitch. I'll get back to you and let you know. If
it still does not work for me, it may have something to do with the
third-party application I'm running with Word.

Regards,

Alan Stancliff
> It only spell checks section 2 in my document?
Alan Stancliff - 10 Mar 2008 07:59 GMT
Hi Graham,

It sure seems that it should work. It does skip spell checking section
one and does spell check section 2. But it also definitely spell checks
section 3, and I am not running any third-party applications just now as
I test it.

I wonder why that is?

Regards,

Alan Stancliff

> That is odd, Graham. I will check it out again this evening after work.
> Perhaps it was just a glitch. I'll get back to you and let you know. If
[quoted text clipped - 5 lines]
> Alan Stancliff
>> It only spell checks section 2 in my document?
Graham Mayor - 10 Mar 2008 09:19 GMT
The document I was using had no proofing set throughout. If the document has
the proofing option set then the spell check does appear to continue past
the end of second section. To overcome this, when all else fails hit it with
a blunt instrument ;)

Sub SpellSec2()
Dim rDoc As Range
Dim Sec2 As Range
   Set rDoc = ActiveDocument.Range
   With rDoc
       .Select
       #If VBA6 Then
           .NoProofing = True
       #End If
   End With
   Set Sec2 = ActiveDocument.Sections(2).Range
   With Sec2
       .Select
       #If VBA6 Then
           .NoProofing = False
       #End If
       .LanguageID = wdEnglishUS
       .CheckSpelling
   End With
End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Hi Graham,
>
[quoted text clipped - 18 lines]
>> Alan Stancliff
>>> It only spell checks section 2 in my document?
Alan Stancliff - 10 Mar 2008 13:10 GMT
Hi Graham,

Yup, that did it. Thanks.

I do have one other question though. You talk about hitting it with a
blunt object. Perhaps a bit more finesse is called for. Would you go for
a precision sledge hammer? I've been trying to get the boss to get me
one of those, along with a glass of hot chocolate, a bickie, and a
little mattress to roll out under my desk to take an afternoon nap when
it gets too frustrating.

Regards,

Alan Stancliff

> The document I was using had no proofing set throughout. If the document has
> the proofing option set then the spell check does appear to continue past
[quoted text clipped - 21 lines]
>     End With
> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.