Spell check Macro Error in Protected Form

S

Silena K-K

Hi there

I have copied the macro referred to in the discussion group for running the
spell check in a protected form.

The first time I ran the macro in my form it worked fine. Now each time I
try to run the macro I get a Microsoft Visual Basic dialog box that says
"Compile Error: Can't find project or library".

The following line of code is highlighted in yellow...

Private Sub CheckProtectedSection(oSection As Section)

....and the word Left$ under the instruction line 'The following subroutine
won't be called if Word 97 is in use ... is selected

Please help. Thank you Silena
 
G

Graham Mayor

Try this simpler version of the code Add any password in the two places
indicated and set the required proofing language also where indicated.

Sub SpellCheckForm()
Dim i As Integer
Dim bProtected As Boolean
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
'check each formfield for spelling
For i = 1 To ActiveDocument.FormFields.Count
ActiveDocument.FormFields(i).Select
#If VBA6 Then
Selection.NoProofing = False
#End If
'set language as appropriate
Selection.LanguageID = wdEnglishUK
Selection.Range.CheckSpelling
Next
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Silena K-K

Hi Graham

The macro works great in a DOC file however, it comes up with the Compile
Error in a DOT file

Any thoughts?

Regards, Silena
 
G

Graham Mayor

The macro should be stored in the template that creates the form (not the
normal template if you are distributing the template) and is probably best
run from a toolbar button in that template. Which line of code is flagged by
the error when you click 'debug' on the error message - see also
http://www.gmayor.com/installing_macro.htm

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Silena K-K

Thank you Graham - you are a star!

Graham Mayor said:
The macro should be stored in the template that creates the form (not the
normal template if you are distributing the template) and is probably best
run from a toolbar button in that template. Which line of code is flagged by
the error when you click 'debug' on the error message - see also
http://www.gmayor.com/installing_macro.htm

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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