Protect the form when exiting a field 
Author Message
 Protect the form when exiting a field

I need to unprotect the document, to allow users insert a digital signature
to a field in a form created in Word. After the field is exited, the
document should be re-protected. I created the following macro, but the
re-protect function doesn't work. I also tried the same function without
"if" (ActiveDocument.Protect Type:=wdAllowOnlyFormFields), but got a message
"the document is already protected. Any solution??

Sub Enablesignature()

   ' UnProtect the document.
   ActiveDocument.Unprotect

End Sub

Sub Protectaftersignature()

' Re-Protect the document.
   If ActiveDocument.ProtectionType = wdNoProtection Then
      ActiveDocument.Protect Type:=wdAllowOnlyFormFields
   End If

End Sub



Tue, 14 Oct 2003 19:10:30 GMT  
 Protect the form when exiting a field
Hi Karen,

Well, if the document IS unprotected then "exiting the field" will not trigger
the macro to execute. So, how is this macro being called? And what version of
Word is this? How do the users select/insert the signature (I doubt it's
digital; is it a graphics file)?

Quote:
> I need to unprotect the document, to allow users insert a digital signature
> to a field in a form created in Word. After the field is exited, the
> document should be re-protected. I created the following macro, but the
> re-protect function doesn't work. I also tried the same function without
> "if" (ActiveDocument.Protect Type:=wdAllowOnlyFormFields), but got a message
> "the document is already protected. Any solution??

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Tue, 14 Oct 2003 22:10:12 GMT  
 Protect the form when exiting a field
I've used the same macro (Re-protect the document) earlier in a case, when
macro automatically inserts AutoText to a field. There it worked as I was
able to define the function (Insert AutoText)  allowed between Protect ->
Unprotect. In this case, I want to unprotect the document when entering to
the field (it works), allow the user to either insert text or a graphics
file (signature) to the field. When exiting, the document should be
re-protected again. I'm using Word2000.



Quote:
> Hi Karen,

> Well, if the document IS unprotected then "exiting the field" will not
trigger
> the macro to execute. So, how is this macro being called? And what version
of
> Word is this? How do the users select/insert the signature (I doubt it's
> digital; is it a graphics file)?

> > I need to unprotect the document, to allow users insert a digital
signature
> > to a field in a form created in Word. After the field is exited, the
> > document should be re-protected. I created the following macro, but the
> > re-protect function doesn't work. I also tried the same function without
> > "if" (ActiveDocument.Protect Type:=wdAllowOnlyFormFields), but got a
message
> > "the document is already protected. Any solution??

> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister
> http://www.mvps.org/word
> http://go.compuserve.com/MSOfficeForum

> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)



Tue, 14 Oct 2003 22:48:13 GMT  
 Protect the form when exiting a field

Karen,

Quote:
> I've used the same macro (Re-protect the document) earlier in a case,
> when macro automatically inserts AutoText to a field. There it worked
> as I was able to define the function (Insert AutoText)  allowed
> between Protect -> Unprotect.

That's the reason it worked -- the macro, not the user, did everything
between the unprotecting and the reprotecting.

Quote:
> In this case, I want to unprotect the document when entering to
> the field (it works), allow the user to either insert text or a
> graphics file (signature) to the field.

You can't.  The document becomes a non-form -- i.e., does not behave
like a form, ignores the meaning of any entry or exit macros -- when
it's unprotected.

You could get around this by making the macro prompt the user for
input -- for example, have the entry macro pop up an InputBox that
asks for text, which the macro then inserts into the document.  The
macro would then reprotect the form and the user could continue by
tabbing or mouseclicking another field.


------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------



Tue, 14 Oct 2003 23:28:42 GMT  
 Protect the form when exiting a field
Hi Karen,

Mark explains why it can't work. What I usually do is .Display the
appropriate dialog box so that the user can select the item (AutoText,
graphic file, whatever), then have a macro take care of actually
inserting, formatting, etc.

Quote:
> In this case, I want to unprotect the document when entering to
> the field (it works), allow the user to either insert text or a graphics
> file (signature) to the field. When exiting, the document should be
> re-protected again.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Thu, 16 Oct 2003 01:36:12 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Protected Forms and Text Form Fields

2. selecting form fields in a protected form

3. Loss of form field text after unprotecting and protecting a form

4. Close Form on Exiting a field?

5. On-Exit macro for Checkbox Form field - getting it to fire upon Print or Save

6. Form Field - Run On Exit

7. Form field exit macro too shy

8. Text form fields - on exit macro problem

9. URGENT: Error when assigning long strings to Form Fields in a protected Word document

10. Protecting custom Form fields

11. Filling in Form Fields while Protected

12. Need help w/Protected document with form text fields and check boxes

 

 
Powered by phpBB® Forum Software