View Single Post
  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default add spellcheck in a locked form

Open the vba editor with the form template open and copy and paste the code
to the template project - see http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

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



CJ wrote:
I'm using a template. I tried to move the macro as you suggested from
normal.dot to my template using the organizer, however "move" is not
an option, so I tried "copy" and it said "the project item cannot be
copied". I guess I don't know how I move the macro to have it
embedded into the template. Can you try again, maybe with a few
more details?

Thank you.



"Graham Mayor" wrote:

Documents with macros have security implications that will cause
users to fret and make them unavailable. If you are distributing
this form to fellow workers, then save it as a template and
distribute the template. Users can then create new forms from the
template.

Move the macro from normal.dot to the template using the organizer.
If you want the macro to also print the document, then add the line

ActiveDocument.PrintOut

immediately before End Sub

If you want it to run from the print button on the standard toolbar
then rename the macro

Sub FilePrintDefault()

--

Graham Mayor - Word MVP

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




CJ wrote:
Thank you very much for that. I was able to build the macro and
apply it to my toolbar and it is working well.

Now my next challenge is that I would like to insert it into the
document . I don't want to have to build macros on 70 company
computers, so I would like to have it in the document, ideally since
this is spellcheck, I would like to have it initiallize upon
selecting the "print" button. Is this possible? If so, can you
walk me through it?

Thank you very much!


"Graham Mayor" wrote:

If this is a simple form without separate sections in which you
simply want to check the field entries, you can simplify the code
to the following - adding your password between the quotes at the
two locations indicated.

The error you are experiencing suggests you have not added the
CheckProtectedSection routine listed on the quoted page.

See http://www.gmayor.com/installing_macro.htm

If you want to spell check a form, then the user of the form must
have access to the macro, which can be saved in the form template
the user's normal.dot template, or the document itself, but if
saved in the document there are macro security implications which
could render it unavailable to many users. You can either run it
from a toolbar button or on exit from a field the user will tab
out of.

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
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

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





CJ wrote:
I am having the same problem with a document using Word 2003. I
have tried following those directions in the link, but I get an
error. It errors on the line that reads..... "Call
CheckProtectedSection(oSection)"

Any suggestions?

Second question, how can you put this into the template for
spellchecking in lieu of having a to build a macro and having it
on the toolbar?

Thank you,

CJ

"Jay Freedman" wrote:

See
http://www.word.mvps.org/FAQs/Macros...ProtectDoc.htm.
Yes, it should be easier than that, but it isn't.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

agates wrote:
I create several of forms in word for our staff. Is there a way
that you can spell check in a field that is in a locked form.
The spell check under tools is not availabe when the form is
locked.