VBA language to Protect Document

R

Ricki Miles

I am currently working on a Word XP template that will unprotect a form,
delete certain text, and then reprotect the form. I have the correct
language to unprotect the form, but cannot seem to get the right language to
reprotect it (and not lose the data already filled in). I would appreciate
any help.

Thanks,

Ricki
 
M

Mark Tangard

Hi Ricki,

It's comfortably squirreled away in a parameter you'd never
think to look for... unless you checked the helpfile. ;)

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
 
M

mksmith

This code is a little scruffy, but it may give you a start. I have
found this in one of my work files.

Malc
www.dragondrop.com



Public Function DocumentProtectionLevel() As Long

On Error Resume Next

If Documents.Count > 0 Then
DocumentProtectionLevel = ActiveDocument.ProtectionType
End If

End Function


Public Sub DocumentUnProtect()

On Error Resume Next

If Documents.Count > 0 Then
ActiveDocument.Unprotect
End If

End Sub


Sub DocumentProtect()

On Error Resume Next

If Documents.Count > 0 Then
ActiveDocument.Protect Password:="", NoReset:=True,
Type:=gnDocumentProtectionLevel
End If

End Sub
 

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