I asked the question Friday if I could create a macro that would print 3
copies of a one page document with each copy having different footer text.
Greg instructed me on the macro and it worked great. The problem I am having
is that the document has form fields in it, and when the document form field
are protected and the macro is run I get an error with no text. I assume
it's because of the protection. How can I avoid the error from appearing
while still having the document protected?

Problem with previous post re: individual footers for each copy ma by Stephanie

Stephanie
Mon Apr 11 10:46:33 CDT 2005

Hi, Josh,

You can have the macro unprotect the forms to do what it
needs to do and then reprotect them before it ends ... so
they are never unprotected to the user.

To unprotect, use the method:

ActiveDocument.Unprotect Password:="xxx"

Leave out the password variable if you don't use one.

To reprotect, use this method:

ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True,Password:="xxx"

Note that the NoReset variant is essential because
otherwise, you'll lose the values that have been entered
in your form fields.

When I use this, I always add a condition (i.e., check if
it's protected before you unprotect and vice versa (using
an If statement), to avoid throwing an error). And, I
recommend putting the protect method into an error
handler to ensure that your document remains protected to
the user, even if the macro happens to throw an error for
any reason.

Hope that helps!

Stephanie Krieger
author of Microsoft Office Document Designer (from MS
Learning)
blog: arouet.net

>-----Original Message-----
>I asked the question Friday if I could create a macro
that would print 3
>copies of a one page document with each copy having
different footer text.
>Greg instructed me on the macro and it worked great.
The problem I am having
>is that the document has form fields in it, and when the
document form field
>are protected and the macro is run I get an error with
no text. I assume
>it's because of the protection. How can I avoid the
error from appearing
>while still having the document protected?
>.
>

RE: Problem with previous post re: individual footers for each copy ma by Josh

Josh
Mon Apr 11 11:59:03 CDT 2005

Thank you Stephanie, I greatly appreciate your help.

Sincerely,

Josh Hallenbeck

"Stephanie Krieger" wrote:

> Hi, Josh,
>
> You can have the macro unprotect the forms to do what it
> needs to do and then reprotect them before it ends ... so
> they are never unprotected to the user.
>
> To unprotect, use the method:
>
> ActiveDocument.Unprotect Password:="xxx"
>
> Leave out the password variable if you don't use one.
>
> To reprotect, use this method:
>
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
> NoReset:=True,Password:="xxx"
>
> Note that the NoReset variant is essential because
> otherwise, you'll lose the values that have been entered
> in your form fields.
>
> When I use this, I always add a condition (i.e., check if
> it's protected before you unprotect and vice versa (using
> an If statement), to avoid throwing an error). And, I
> recommend putting the protect method into an error
> handler to ensure that your document remains protected to
> the user, even if the macro happens to throw an error for
> any reason.
>
> Hope that helps!
>
> Stephanie Krieger
> author of Microsoft Office Document Designer (from MS
> Learning)
> blog: arouet.net
>
> >-----Original Message-----
> >I asked the question Friday if I could create a macro
> that would print 3
> >copies of a one page document with each copy having
> different footer text.
> >Greg instructed me on the macro and it worked great.
> The problem I am having
> >is that the document has form fields in it, and when the
> document form field
> >are protected and the macro is run I get an error with
> no text. I assume
> >it's because of the protection. How can I avoid the
> error from appearing
> >while still having the document protected?
> >.
> >
>