Word 2003 Form with unprotected doc properties?


T

Thomas Svensson

Hi
I have a form with different form objects and it's working as it should. My
problem is that when I protect the document it also protects the document
properties and the fields i my document header that is using filds from the
properties.
Is it possible to "unprotect" the properties and the header?

Regards
Thomas Svensson
 
Ad

Advertisements

S

Stefan Blom

Switching to Print Preview and then back to your favorite view would update
fields in the header.
 
T

Thomas Svensson

Hi
Thank you for responding. You suggestion updates the fields in the header,
but how can I enter information in the property fields? When opening up the
property dialog box, all property fields are greyed out due to that the
document is protected. Is there a way to "unprotect" these?

/Thomas

"Stefan Blom" skrev:
 
G

Graham Mayor

You cannot update them while the form is protected. What information do you
wish to place in the properties and to what end?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

Thomas Svensson

Hi
The header consists among other information fields as Author, Title and
Subject that is from the doc properties. I have to follow our corporate
document policy for the layout ant content of the header

/Thomas

"Graham Mayor" skrev:
 
G

Graham Mayor

In that case you would need to unlock the form by macro in the form template
and apply the relevant new properties pertaining to the document, lock the
document and update the fields. This can all be achieved by macro.

The author will be set by default.

Are the the title and subject related to the content of the form? If so you
can pull the data from the relevant fields. If not you would need to prompt
for it. Something along the lines of

Dim i As Integer
Dim bProtected As Boolean
Dim sPassword As String
Dim sTitle As String
Dim sSubject As String
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oField As Field
sPassword = ""
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect _
Password:=sPassword
End If

'Do your thing
sTitle = InputBox("Enter the document title", _
"Document Title", _
ActiveDocument.BuiltInDocumentProperties("Title"))
'or e.g.
'sTitle = ActiveDocument.FormFields("Text1").Result
sSubject = InputBox("Enter the document subject", _
"Document Subject", _
ActiveDocument.BuiltInDocumentProperties("Subject"))
ActiveDocument.BuiltInDocumentProperties("Title") = sTitle
ActiveDocument.BuiltInDocumentProperties("Subject") = sSubject
With ActiveDocument
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Update
Next oField
End If
Next oFooter
Next oSection
End With

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=sPassword
End If

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Ad

Advertisements

T

Thomas Svensson

Thanks a lot. This will do the trick for me.

/Thomas

"Graham Mayor" skrev:
 
Ad

Advertisements


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