Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

COM object model not functioning after encrypting the word document using office extention

Avatar

Level 2

     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.

Sub hi()
    Dim i As Integer
   
    i = ThisDocument.Fields.Count
   
    MsgBox i   
    
End Sub

     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.

5 Replies

Avatar

Level 8

I'm validating but if I remember correctly RM disables macros to ensure the secure integrity of the document.

Avatar

Level 8

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

Avatar

Level 2

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")
msgbox doc.Fields.count
doc.close
a.quit

_______________________________________________________

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. 

Avatar

Level 8

Are you using single sign on?  If not I'm not surprised it isn't working because how would the app authenticate?

Avatar

Level 2

No, I am not using SSO, when opening the document, the office extention will open a dialog promping me to input username and password.