Intercepting Protect Event?

B

BobZ

I'm trying to protect my Word doc by making sure all hiddend text is hidden
and keeping the protected doc locked by not allowing the user to use the
Protect Form (ProtectForm) button. I've done it for the ShowHide button, but
don't know VBA syntax enough to do it for protect. This is what I've done so
far with the help of others:

Private Sub Document_Open()
'Hides all hidden text when the form is first opened.
ActiveWindow.View.ShowAll = False
ActiveWindow.View.ShowHiddenText = False

'Protects the form if it's been unprotected.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.protect wdAllowOnlyFormFields, noreset:=True
End If
End Sub

Sub ShowAll()
'Intercepts ShowAll command to prevent display of hidden text
ActiveWindow.ActivePane.View.ShowAll = False

End Sub

I've tried using the VBE but just don't know enough. Can someone help?

Thanks!
 
J

Jonathan West

BobZ said:
I'm trying to protect my Word doc by making sure all hiddend text is
hidden
and keeping the protected doc locked by not allowing the user to use the
Protect Form (ProtectForm) button. I've done it for the ShowHide button,
but
don't know VBA syntax enough to do it for protect. This is what I've done
so
far with the help of others:

Private Sub Document_Open()
'Hides all hidden text when the form is first opened.
ActiveWindow.View.ShowAll = False
ActiveWindow.View.ShowHiddenText = False

'Protects the form if it's been unprotected.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.protect wdAllowOnlyFormFields, noreset:=True
End If
End Sub

Sub ShowAll()
'Intercepts ShowAll command to prevent display of hidden text
ActiveWindow.ActivePane.View.ShowAll = False

End Sub

I've tried using the VBE but just don't know enough. Can someone help?


Why not set a protection password on the protected document? Then they won't
be able to unprotect it without the password.

Beware that even this is not very strong protection. Knowedgeable users will
know how to get at the content anyway. But this will protect against casual
or accidental changes
 
B

BobZ

Ahem....gold star for thinking simple. I guess I got so wrapped up with
learning VBA I didn't think about that. I'm not worried about sophisticated
users in this case--there's really no gain for them to purposefully alter
this doc. I'm just trying to prevent accidental issues. So this will work!

Thanks for the help!
 

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