After encrypting A word document using office extention, it seems like the COM object model becomes unusable. I cannot not manipulate the encrypt document through COM interface, nor can I write macro VBScript to do some operation on the docuent.
For example, I create a word Macro with some simple code.
Dim i As Integer
i = ThisDocument.Fields.Count
If the document is not encrypt, then we will see a msgbox which tells us the number of bookmarks in the current document.
Now, encrypt the word document using the office extention, running the macro code will fail with error code " 80004005" and error message:Method 'Fields' of bject 'ThisDocument' failed.
It is very important for us to manipulate word documents through COM interface in our system, I want to know why the COM interface does not work anymore after the document is encrypted.
I did get a response and it will depend upon what rights are enabled and what macro functions are being utilized. For example Application.MergeDocuments is always disabled. Application.Dialogs is enabled with copy and edit
I take macro script as an example to demonstrate that word COM object model cannot be used after encripted. Actually you can reproduce the same problem when you manipulate word document through COM interface using any programming language.
For example, you can create a text document with the following VBscript:
set a = createobject("Word.Application")
set doc = a.Documents.Open("E:\temp\test.docx")
Save the document with ".vbs" file extention and then run it by double clicking it. it will fail if the document is encrypted using the office extention.