Word page formatting with protection on

S

Sonya Nash

I am trying to protect field references that are embedded in the body of a
paragraph. I have been able to do so using protection and exceptions. Once
that is in place page setup is no longer editable. Can someone offer a
solution?
 
G

Gordon Bentley-Mix

Sonya,

This is standard Word functionality; if a document is protected, access to
the Page Setup functionality is restricted. You would need to unprotect the
document first to gain access to this functionality again. You might be able
to write a macro that unprotects the document, displays the Page Setup dialog
box and then re-protects the document again, but you would not be able to use
any sort of method designed to intercept the standard File | Page Setup
command because (as you have no doubt seen) this menu command is disabled
when the document is protected. Instead you would have to provide an
alternate means of access to your macro - possibly through a custom toolbar
button or menu command. The code would look something like this:

Sub SetupPage()
Dim ProtectionType As Long
' Create a variable to store the current protection type
ProtectionType = ActiveDocument.ProtectionType
' Record the current protection type
' (which will be 0 if the doc isn't protected and NOT 0 if it is)
If ProtectionType <> 0 Then ActiveDocument.Unprotect "password"
' If the doc is protected then unprotect it
' supplying the password (if one is required)
Dialogs(wdDialogFilePageSetup).Show
' Show the Page Setup dialog box (which will be modal so the user
' can't get "behind" it and change something)
If ProtectionType <> 0 Then ActiveDocument.Protect ProtectionType, True,
"password"
' When the dialog box is closed, re-protect the document using
' the same protection type as it had to begin with, setting the
' NoReset argument to "True" (so any formfields in the document
' aren't reset) and supplying the password (if one is required)
End Sub

--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
S

Sonya Nash

Thanks for the reply. Not the answer I was hoping for, but I appreciate all
the detail on the macro.
 

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