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

Hmm... hmm... hmm...

~scratching head~

Interesting possibilities abound! But I think I've just about exhausted the
budget on this project. Time to put this one in the too-hard bin and tell the
client to live with the limitation - at least until the next release.

Altho if the code-invoked Spelling dialog is modal, it might be enough just
to unlock the document and call it. However, it still doesn't get around the
problem with spellchecking the protected sections, which opens another can of
worms entirely... Best just left, methinks.
--
Cheers!
The Kiwi Koder

"Jean-Guy Marcil" wrote:

> "NZ VBA Developer" wrote:
>
> > 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
>
> In this case, have you looked up the
> Sections(n).ProtectedForForms
> property?
>
> You can use that to establish which sections are protected, for example:
>
> Dim i As Long
> Dim strTest As String
>
> With ActiveDocument.Sections
> For i = 1 To .Count
> If .Item(i).ProtectedForForms Then
> strTest = ""
> Else
> strTest = "not "
> End If
> MsgBox "Section " & i & " is " & strTest & "protected.", _
> vbInformation, "Results"
> Next
> End With
>
> Now, whether or not you can use that to spell check target sections or not
> is another matter... Spell checking ranges is hard to handle an sometimes
> unpredictable.
>
> Also, you do not have to worry about modality... The Code-invoked Spelling
> dialog is modal... user cannot get behind it... which is different from when
> you invoke it through the UI...
>
> Good luck!