Unprotect not unprotecting properly

S

Simon

Hi,
I have a simple macro that is meant to unprotect a document as
follows, but for some reason the document still has protection turned
on afterwards. Looking at the XML, this line remains
<w:documentProtection w:edit="read-only" w:enforcement="off"/>
but Word 2003 seems to ignore the bit that says "off" the next time it
is loaded. If I remove the line from the xml, save as .doc and reload
it then there is no problem. Am I unprotecting the document in the
right way? If not how can I ensure that the document contains no
reference to documentProtection. Is it possible there is some bug in
Word 2003 (SP1, 11.6359.6360)?

The part that unprotects:
~~~~~~~~
Sub ResetDocument(strDocumentName As String, strDocumentFolder As
String, strDocumentId As String)
Dim ActiveDocument As Document
'load the doc
Set ActiveDocument = Documents.Open(strDocumentFolder &
IIf(Right(strDocumentFolder, 1) = "\" Or Right(strDocumentFolder, 1) =
"/", "", "\") & Replace(strDocumentName, "[ID]", strDocumentId))
' Remove custom properties

ActiveDocument.Unprotect "kms." &
CStr(ActiveDocument.CustomDocumentProperties("Document ID"))
ActiveDocument.CustomDocumentProperties("Document ID").Delete
ActiveDocument.CustomDocumentProperties("Article ID").Delete
ActiveDocument.CustomDocumentProperties("Return URL").Delete
ActiveDocument.CustomDocumentProperties("Checked in").Delete
ActiveDocument.CustomDocumentProperties("Saved locally").Delete
ActiveDocument.CustomDocumentProperties("Taxonomy ID").Delete
' Remove macros
Application.OrganizerDelete ActiveDocument.FullName, "KmsClient",
wdOrganizerObjectProjectItems
' Limit menu bar changes to the relevant document only
CustomizationContext = ActiveDocument
' Rename "File Save Local Copy" menu option as "File Save"
RenameMenuItem ActiveDocument, "File", "Save Local Copy", "&Save"
' Rename "File Check In to KMS" menu option as "File Save As Web
Page"
RenameMenuItem ActiveDocument, "File", "Check In to KMS", "Save As
Web Pa&ge..."
' Close the document, saving changes
ActiveDocument.Save
ActiveDocument.Close
ShutDown strDocumentFolder
End Sub
~~~~~~~~

The document has been protected like this:

~~~~~~~~
Sub CheckIn(checkInDoc As Document)

' Mark the document as checked in
ActiveDocument.CustomDocumentProperties("Checked in").Value = True
' Protect against further changes
On Error Resume Next
checkInDoc.Unprotect Password:="kms." &
checkInDoc.CustomDocumentProperties("Document ID").Value
checkInDoc.Protect wdAllowOnlyReading, Password:="kms." &
checkInDoc.CustomDocumentProperties("Document ID").Value
' Save local copy
checkInDoc.Save
checkInDoc.Close
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