Protection/Sections

S

Starbird

I have a template with several sections and several different procedures. In
one procedure I need to unprotect 2 sections leaving the others protected. I
have found the following code:

Sub ToolsProtectUnprotectDocument()

Dim oDoc As Document
Set oDoc = ActiveDocument

On Error GoTo ErrMess
If oDoc.ProtectionType = wdNoProtection Then
With Dialogs(wdDialogToolsProtectDocument)
.noreset = True
.Show
End With
Else
oDoc.Unprotect
End If
Exit Sub

ErrMess:
MsgBox Err.Description, vbInformation

End Sub

Sub ProtectForm()
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
ActiveDocument.Unprotect
Else
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
End If
End Sub

That works great, except it brings up the "Protect Document" dialog box. I
don't want the users to have any options, I simply want the 2 sections to
unprotect long enough to update the information without dumping the data in
all the form fields in other sections.

Any assistance would be greatly appreciated!!!
SRD
 
D

Doug Robbins

Replace:

With Dialogs(wdDialogToolsProtectDocument)
.noreset = True
.Show
End With

With

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
S

Starbird

Thanks Doug, this works great with one ?small? exception -
Everything is working correctly, but now when my other procedures run I get
an empty error msgbox (just the red x icon, empty help). When I close it the
procedure appears to have run fine, so I have no idea what it is?

SRD
 

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