Group: microsoft.public.word.vba.general
From: =?Utf-8?B?TlogVkJBIERldmVsb3Blcg==?=
Date: Tuesday, April 08, 2008 4:41 PM
Subject: Re: Spellchecking a Protected Document

Graham,

Thanks for the suggestion. I'll have to test it to see if it meets my needs;
however, I see a couple of problems straight away:

First, it's not the protected sections that I want to spellcheck; it's the
_unprotected_ ones, and the users want to be able to use Word's native
'Spelling and Grammar' dialog to do this. Does
'Selection.Range.Checkspelling' invoke this dialog or just do the 'red
squiggly underline' thing?

Second, the sections that are unprotected vary from document to document, so
it's not always possible to use hardcoding to specify which sections to check
- altho it's a bit of a moot point in light of the above.

And finally, if this code does invoke the 'Spelling and Grammar' dialog,
this dialog is not modal to Word. Consequently, 'ActiveDocument.Unprotect'
will cause me no end of grief, as the users will just run the spellchecking
macro and then hop in behind the dialog and start mucking about with the
stuff that's meant to be protected. (I could write great code if it weren't
for the bloody users!)

Anyway, thanks for the suggestion. I think I'll just tell the client that
they can't have full functionality from the 'Spelling and Grammar' dialog due
to a limitation in Word. I've had to do that often enough with other things
that they're getting used to it now. ;-D

--
Cheers!
The Kiwi Koder


"Graham Mayor" wrote:

> How about limiting the spell check macro to the range that you actually want
> spell checked? eg for section 2
>
> Sub SpellCheckForm()
> Dim i As Integer
> Dim bProtected As Boolean
>
> With ActiveDocument
> If .ProtectionType <> wdNoProtection Then
> bProtected = True
> .Unprotect Password:=""
> End If
>
> .Sections(2).Range.Select
> With Selection
> #If VBA6 Then
> .NoProofing = False
> #End If
> .LanguageID = wdEnglishUK
> .Range.CheckSpelling
> End With
>
> If bProtected = True Then
> .Protect _
> Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
> End If
> End With
> End Sub
>
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> NZ VBA Developer wrote:
> > This seems to be a popular topic lately, so I thought I'd chime in as
> > well.
> >
> > While the article at
> > http://word.mvps.org/faqs/macrosvba/SpellcheckProtectDoc.htm is great
> > if you want to check the spelling of the information input into
> > formfields, my problem is a bit different. I have (Word 2003)
> > templates that produce forms-protected documents, but the documents
> > themselves don't contain any formfields. I use forms protection only
> > because it allows me to protect only certain sections of the
> > document, such as the header and footer, while leaving other
> > sections, such as the main body of the document unprotected.
> >
> > The spellchecker checks the spelling in the unprotected sections OK,
> > and I don't really mind if it doesn't check the spelling in the
> > protected sections because 1) I know that I haven't made any spelling
> > errors in the 'boilerplate' in these sections; and 2) if the user has
> > made a spelling error in the 'variable' information, they can just
> > rerun the code in template to correct the errors. However, there is a
> > deficiency in the native spellchecker that I've been asked to develop
> > a workaround for.
> >
> > In an unprotected document, if none of the choices in the
> > 'Suggestions' list are viable, you can just type in the 'Not in
> > Dictionary' box to make the change. However, this doesn't work in a
> > protected document; the text in the 'Not in Dictionary' box is
> > treated like it's in a protected section. I could always write code
> > that unprotects the document before displaying the spellchecker, but
> > there are a couple of drawbacks:
> >
> > First, this will allow the users to spellcheck the protected sections
> > as well, which is not really a major problem except that if the user
> > corrects an error that was introduced through the input of the
> > 'variable' information described above, this correction won't get
> > replicated back into the data from the UserForm. Thus if the user
> > reruns the template, the correction won't be there and the error
> > could be reintroduced without the user realising it. However, I can
> > live with this.
> >
> > The real problem is that the spellchecker dialog isn't modal to Word.
> > Therefore, if I unprotect the document, the user now has full access
> > to the whole document, _including_ the protected sections. And
> > believe me, the users will take advantage of this whenever possible;
> > I learned this when I told the users I was going to fix a bug in my
> > code that left the document unprotected and got a... umm... less than
> > favourable response. ;-D
> >
> > Does anyone know a way to enable the editing capability in the 'Not in
> > Dictionary' box without unprotecting the document? Or will my users
> > just have to live with this limitation? (The second choice is
> > acceptable as I'm quite happy to tell the users 'No' - as long as I
> > can justify the response.)
>
>
>

Safety Articles | Usenet Groups | Usenet News | Bluegrass