Hi Ana
I'm not sure how much you know so forgive me if I'm teaching you to suck sggs
Since posting this I have found out that if you protect a Word document
(even a small section) it severely affects its operability - TOC, spelling
checkers etc don't perform.
I haven't found a way to resolve this here is my workaround I used. I was
protecting sections to support forms that held information in bookmarks so
that I could refer to them later in the document. Instead of doing this I
used a macro that starts when the user opens the document. It collects and
stores the information in the document properties - (the user can change them
by going into file.Properties etc). If the user doesn't change a property (or
the property is blank) it nags them each time they open the document. Then I
used the insert.field command in the document to use the properties in my
document.
There is a danger that a user will over type a reference in the document but
I'll live with that. Heres the code I used. Go to tools.macro.macros type
AutoOpen in the Macro name field and press create. Select all the text
presented in the windo and paste the following ... then play with it till it
does what you want
Hope that helps
Ian
---------------------------------
Sub AutoOpen()
' Store document variables in document properties
'
Dim bUpdated
MsgBox "This document contains fields that update automatically. If you
need to change the Project Name, Client or Contract Number after you have
specified them, update them in the File -> Properties dialog box"
bUpdated = 0
bUpdated = bUpdated + UpdateVar(wdPropertyAuthor, ActiveDocument, 2, 1,
"Please enter the name of the Document Owner", "Document Owner", "")
bUpdated = bUpdated + UpdateVar(wdPropertySubject, ActiveDocument, 2, 1,
"Please enter the name of the Project", "Project Name", "Project Name")
bUpdated = bUpdated + UpdateVar("Client", ActiveDocument, 2, 2, "Please
enter the name of the Project Client", "Client Name", "the Client")
' If bUpdated Then ActiveDocument.Fields.Update
ActiveDocument.Fields.Update
End Sub
Function UpdateVar(sVarName, oDocument, iMode, iVarChar, sVarDialogRequest,
sVarDialogTitle, sDefault)
'check and update variables in custom properties
' imode options as follows;
' 0 = replace value if exists (not supported)
' 1 = delete value if exists (not supported)
' 2 = ignore and return if exists otherwise update
' iVarChar (variable characteristics) as follows
' 0 = Word variable (not supported)
' 1 = Built in property
' 2 = Custom property
Dim temp, bChanged
bChanged = False
Select Case iVarChar
Case 1 ' built in property
' Test if contains a value
temp = ActiveDocument.BuiltInDocumentProperties(sVarName).Value
Select Case iMode
Case 2 ' ignore and return if exists otherwise update
If (Trim(temp) = "") Or (Trim(temp) = sDefault) Then
'ask for value and populate property
sVarValue = InputBox(sVarDialogRequest, sVarDialogTitle)
If sVarValue <> "" Then
ActiveDocument.BuiltInDocumentProperties(sVarName).Value = sVarValue
bChanged = True
End If
End If
Case Else
MsgBox "Error: inappropriate iMode in UpdateVar"
End Select
Case 2 ' custom property
'NOTE should probably test if property exists but as we are distributing
' the document with the custom properties and used for internal use is
acceptable
' Test if contains a value
temp = ActiveDocument.CustomDocumentProperties(sVarName).Value
' ActiveDocument.CustomDocumentProperties("Client").Value =
sClient
Select Case iMode
Case 2 ' ignore and return if exists otherwise update
If (Trim(temp) = "") Or (Trim(temp) = sDefault) Then
'ask for value and populate property
sVarValue = InputBox(sVarDialogRequest, sVarDialogTitle)
If sVarValue <> "" Then
ActiveDocument.CustomDocumentProperties(sVarName).Value = sVarValue
bChanged = True
End If
End If
Case Else
MsgBox "Error: inappropriate iMode in UpdateVar"
End Select
Case Else
MsgBox "Error: inappropriate iVarChar in UpdateVar"
End Select
UpdateVar = bChanged
End Function