PDA

View Full Version : Read only for older versions of Word



Hawkansson
01-17-2017, 06:03 AM
Hi,

I have been working in Word 2013, using rich text content controls mapped to custom xmls. Until now I thought that Word 2010 supported that as well, but if I open it in Word 2010 the xml-mapping for the rich text CCs disappears, and when I reopen the file in Word 2013 it says a problem was found with its content.

Now I want to set conditional read only. I want to force read only if the document is opened with a Word version earlier than 2013.

Are there any smart ways to implement something like this?

Best regards,
David

Hawkansson
01-20-2017, 05:24 AM
So this is not possible I suppose? *bump*

gmaxey
01-20-2017, 09:30 AM
I think that all you can really do if you expect to share these documents with Word 2010 users is a) Use compatibility mode and don't use mapped rich text controls or 2) convert to pdf.

Hawkansson
02-07-2017, 12:46 AM
I noticed that if a user opened the document in Word 2010, changed something and then saved it, the document became corrupt, and the mapped rich text content controls disappeared. But if a user didn't change anything the document remained intact. So I solved the issue by a Document.Open event, checking the version and closing the document again if the version was older than 2013.

gmaxey
02-07-2017, 05:16 AM
To be able to share with Word 2010 users perhaps you could do something like this:


Sub Document_Open()
Dim bCompatible As Boolean
On Error Resume Next
bCompatible = ActiveDocument.Variables("Compatible")
If Err.Number <> 0 Then
ActiveDocument.Variables("Compatible") = "False"
bCompatible = False
End If
On Error GoTo 0
If Application.Version < 15# And ActiveDocument.Variables("Compatible") = "False" Then
If MsgBox("This document was created in Word 2013 or higher and contains mapped rich text content controls." & vbCr + vbCr _
& "To view this document in Word 2010 or lower it must be saved as a ..." & vbCr + vbCr _
& "Do you want to ...", vbQuestion + vbYesNo, "COMPATIBILITY") = vbYes Then
Dialogs(wdDialogFileSaveAs).Show
ActiveDocument.Variables("Compatible") = "True"
Else
ActiveDocument.Close ""
End If
End If
End Sub