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: Tue, 23 Sep 2008 13:03:02 -0700,    group: microsoft.public.word.vba.general        back       


strange happenings with document protection code   
So I have a Word document with Form Field protection.  It has code for both 
Document_Close and Document_Open.

Both use this to turn off and turn back on the protection:

If ActiveDocument.ProtectionType <> wdNoProtection Then
    ActiveDocument.Unprotect Password:="<password>"
End If

...and then...

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, 
Password:="<password>"

In between these statements, I have some code that attempts to change the 
font of some form fields, but for some reason, the Document_Open sub 
procedure doesn't work, specifically because it says that form protection is 
on.  Basically, my Unprotect section isn't working on Document_Open.  It 
does, however, work fine on my Document_Close.

What could be the reason for this?  I check the passwords to make sure I 
hadn't fat fingered something, and I haven't.

Any ideas?

Thanks!
date: Tue, 23 Sep 2008 13:03:02 -0700   author:   kill_beast

RE: strange happenings with document protection code   
Furthermore,

When the document is already open, and I run the Document_Open sub procedure 
from the Visual Basic Window, it works fine.  It just doesn't seem to work 
when actually opening the document.





"kill_beast" wrote:

> So I have a Word document with Form Field protection.  It has code for both 
> Document_Close and Document_Open.
> 
> Both use this to turn off and turn back on the protection:
> 
> If ActiveDocument.ProtectionType <> wdNoProtection Then
>     ActiveDocument.Unprotect Password:="<password>"
> End If
> 
> ...and then...
> 
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, 
> Password:="<password>"
> 
> In between these statements, I have some code that attempts to change the 
> font of some form fields, but for some reason, the Document_Open sub 
> procedure doesn't work, specifically because it says that form protection is 
> on.  Basically, my Unprotect section isn't working on Document_Open.  It 
> does, however, work fine on my Document_Close.
> 
> What could be the reason for this?  I check the passwords to make sure I 
> hadn't fat fingered something, and I haven't.
> 
> Any ideas?
> 
> Thanks!
date: Wed, 24 Sep 2008 07:46:02 -0700   author:   kill_beast

RE: strange happenings with document protection code   
One more thing I should've mentioned,

The Unprotect code doesn't work when passwords are all set to "" either.

Just on the Document_Open procedure, and only when the document is actually 
opening (I can manually run the procedure and it works fine).





"kill_beast" wrote:

> So I have a Word document with Form Field protection.  It has code for both 
> Document_Close and Document_Open.
> 
> Both use this to turn off and turn back on the protection:
> 
> If ActiveDocument.ProtectionType <> wdNoProtection Then
>     ActiveDocument.Unprotect Password:="<password>"
> End If
> 
> ...and then...
> 
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, 
> Password:="<password>"
> 
> In between these statements, I have some code that attempts to change the 
> font of some form fields, but for some reason, the Document_Open sub 
> procedure doesn't work, specifically because it says that form protection is 
> on.  Basically, my Unprotect section isn't working on Document_Open.  It 
> does, however, work fine on my Document_Close.
> 
> What could be the reason for this?  I check the passwords to make sure I 
> hadn't fat fingered something, and I haven't.
> 
> Any ideas?
> 
> Thanks!
date: Wed, 24 Sep 2008 11:53:01 -0700   author:   kill_beast

Google
 
Web ureader.com


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