Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Mon, 21 Apr 2008 08:02:32 -0700 (PDT),    group: microsoft.public.word.vba.beginners        back       


protecting a document   
hello all,

I am trying to create a button by recording a macro to protect my
document by limiting formatting option. Here is the code when the
macro is recorded. But when I try to run the macro I get errors, here
is the code. Can someone tell me how to fix  this? thank you.

Sub ProtectFormatting()

    ActiveDocument.protect Password:="anything", NoReset:=False,
Type:=7, _
        UseIRM:=False, EnforceStyleLock:=True

End Sub

The error is: "Parameter value is out of acceptable range"
date: Mon, 21 Apr 2008 08:02:32 -0700 (PDT)   author:   MM

RE: protecting a document   
"MM" wrote:

> hello all,
> 
> I am trying to create a button by recording a macro to protect my
> document by limiting formatting option. Here is the code when the
> macro is recorded. But when I try to run the macro I get errors, here
> is the code. Can someone tell me how to fix  this? thank you.
> 
> Sub ProtectFormatting()
> 
>     ActiveDocument.protect Password:="anything", NoReset:=False,
> Type:=7, _
>         UseIRM:=False, EnforceStyleLock:=True
> 
> End Sub
> 
> The error is: "Parameter value is out of acceptable range"

The values for "Type:=" range from -1 "WdNoProtection" to 3 
"wdAllowOnlyReading".
I guess, from your description, that you need "-1".
date: Tue, 22 Apr 2008 09:14:01 -0700   author:   Jean-Guy Marcil

Re: protecting a document   
I find it helpful to use the defined constants whenever I can.  They
are more readable and mean you don't have to remember values.  You can
look up the constants in the help but they can be automatically listed
for you after you type the ":="  following the parameter name.   If
you have "Auto List Members" turned on in the VBA IDE.

If you don't have this turned on already you can do so by ticking/
checking the "Auto List Members" checkbox in the  "Tools| Options"
"Editor" tab in the VBA IDE.

The valid protection types are;

WdProtectionType can be one of these WdProtectionType constants.
wdAllowOnlyComments
wdAllowOnlyFormFields
wdAllowOnlyRevisions
wdNoProtection


Hope this helps.

Cheers
TonyS.


MM wrote:
> hello all,
>
> I am trying to create a button by recording a macro to protect my
> document by limiting formatting option. Here is the code when the
> macro is recorded. But when I try to run the macro I get errors, here
> is the code. Can someone tell me how to fix  this? thank you.
>
> Sub ProtectFormatting()
>
>     ActiveDocument.protect Password:="anything", NoReset:=False,
> Type:=7, _
>         UseIRM:=False, EnforceStyleLock:=True
>
> End Sub
>
> The error is: "Parameter value is out of acceptable range"
date: Wed, 30 Apr 2008 17:11:43 -0700 (PDT)   author:   Tony Strazzeri

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us