Using Spell Checker on Password Protected Forms in Word

B

Beeliney

Now I know that there is a page with a macro on how to do this, but I can not
for the life of me get this to work and it is beginning to frustrtate me
beyond belief.

Can anyone help me?
What I have done is created a form for a group of people to complete
different parts of. This has been password protected but it is vital that
there is a spell check facility. I am not familiar with the use of macros
and although I have copied one from the internet it appears to remove the
password from the document.

I would appreciate any help
Thanks
 
G

Graham Mayor

The macro shouldn't 'remove' the password, it should apply it, run the spell
function than reset the password. The code below will do the job. Enter your
password in both places indicated between the quotes

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


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


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Beeliney

That was really helpful, thank you.

I now have a new problem!
Once I have set the macro up and protected the form it works brilliantly,
however when I move the document to another computer the macro doesn't move
with the document and hence the spell check only works on the computer that I
wrote it on. Is there a way around this? It could be that I havent done
something simple as I am new to using macros

Many thanks
 
S

Suzanne S. Barnhill

The macro must be saved in the document itself. Better still is to create
the form as a template (containing the macro) and base new documents on it.
When you create or save the macro, make sure to have the correct document or
template selected for "Save macro in."
 
B

Beeliney

Thanks for your help Suzanne, but I am still a little unclear as to what it
is that I actually have done wrong. When I saved the Macro I wasnt able to
specify where to save it to. I also do not know how to create the form as a
template, it is as simple as saving as a template in the save options?

Sorry to sound so uneducated.

Thanks again
 
S

Suzanne S. Barnhill

Yes, you can save the form document as a template. In the Tools | Macro |
Macros dialog, you can use the Organizer to copy the macro from Normal.dot
(where it will have been saved by default) into your document or template.
 
B

Beeliney

Thanks for your help and patience Suzanne.

The macro has successfully been saved into the document and is now
transfered to other computers. However when I try and run the macro a
communication box appears which says:
"The Macros in this project are disabled. Please refer to the online help
or documentation of the host application to determine how to enable macros"

When I go to the help button I get another box telling me that it is
unavailable!

I feel like we are so close now. How do I enable macros?

Thanks once again
 
G

Graham Mayor

If you save macros in the document as opposed to in its template, then you
are at the mercy of the security settings on the PC where the macro is run.
In this case your macro security is set to high. If you set it to medium you
would get a prompt to use the macros - but you have no control over the
macro security level of other users and you shouldn't think of reducing the
macro security below medium.

The best place for the macro is in the template on which the form is based.
The simplest way to do this would be to save the document as a template and
install the template in the user templates folder of the remote PCs or a
shared workgroup folder location.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Beeliney

Thanks once again

However, there is something still not right.
The macro works brilliantly for me, on my computer. I have put it to run on
exit on the field on the form that I require it. Fine. I have saved it onto
the template, however, when I create a document the macro is still attached
to the document but it doesn't run on exit and it needs to be set up again.
This doesn't help my users as some of them can barely open word let alone
anything else!

Sorry for the constant questions

Your help is really appreciated
 
J

Jay Freedman

Beeliney said:
Thanks once again

However, there is something still not right.
The macro works brilliantly for me, on my computer. I have put it to
run on exit on the field on the form that I require it. Fine. I have
saved it onto the template, however, when I create a document the
macro is still attached to the document but it doesn't run on exit
and it needs to be set up again. This doesn't help my users as some
of them can barely open word let alone anything else!

Sorry for the constant questions

Your help is really appreciated

Looks are deceiving...

When you save a macro in a template, and you base a new document on that
template, the macro stays in the template and is not transferred to the
document. Because the document is "attached" to the template on your
computer, the macro is still available -- it isn't really in the document.

When you send the document to another computer, the template is no longer
available to that user. Word attaches the document to their Normal.dot
template (because there must always be some attached template), but that
doesn't contain the macro.

The solution is to send the template instead of a document based on it, with
instructions to save it into their Templates location, and let the users
base new documents on their local copy. Another method is to place the
template in a commonly accessible folder on a network share, and point
everyone's Workgroup folder (in Tools > Options > File Locations) to that
place.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
B

Beeliney

Thanks Jay, but I need people to be able to use the same document and fill in
different fields on the same document.

I am so frustrated with this and am seemingly getting no where and yet I
really feel like there is an obvious solution that I am missing
 
S

Suzanne S. Barnhill

In that case, you need to save the macro in the document rather than in the
template.
 
B

Beeliney

But when I do that it doesnt run on exit, it works for me but not for other
users

If I only protect certain parts of the form will the spell check work on the
unprotected parts? If so then maybe I could remove the text fields and just
leave space for typing, I know that has other problems, but I can look at the
possibilities

Thanks once again, I am feeling very ignorant!
 
S

Suzanne S. Barnhill

"On exit" is very specific: you must tab out of the field; you can't just
move the insertion point with the mouse. Also, other users must have macros
enabled, which gets back to the original problem.
 
G

Graham Mayor

If the macro is saved in the document, then whether or not it will run
depends on the users' macro security over which you should have no control.
Removing the security leaves users vulnerable to malicious documents,
retaining it virtually guarantees that the macros will be disabled either by
the security of the user.

Macros are invariably best stored in templates. By default macros are stored
in normal.dot. Your normal.dot is not available to other users so it would
have to be stored in a document or global template.

The best place to store them is in the document template, but unless your
users are able to share the document template, the document will not be able
to see the macro. Jay has already indicated how you can have the template
shared, by using a common workgroup folder.

If you do not have shared access then either you need to distribute the
document template containing the macro for installation on the users' PCs or
you should supply the macro in a global template which can be installed in
the users' Word startup folders. To facilitate either, copy the macro into
the form document and save the form as a template. Distribute to or share
this template with your users.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Beeliney

Thanks for your seemingly neverending patience.

I have:
Set up a template with the macro running on exit in text fields in a form.
Saved the template onto a shared drive.
Once someone opens the template the macro is attached to the template but is
no longer active in the text fields.

As I say, I am sure that it is something very simple but I can't work out
why it is still there and yet not working.

Thanks once again
 
G

Graham Mayor

The template should be saved in the User templates folder or the Workgroup
folder (tools > options > file locations), for it to be used as a document
template i.e. new documents are created from it. You don't 'open' the
template in order to use it. The mere presence of such a template in the
folder will not apply the macros to the existing form document, unless the
template is attached to the document (tools > templates and add-ins)

If you want the macros to be available to all documents, then they must be
saved in a global template. For global templates other than normal.dot (as
in this instance) that template must be saved in the Word startup folder.
(Tools > Options > File locations). Macros in such a template behave more or
less as if they were stored in the normal template.

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


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


For the macro to work in
 

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