none
Is there a way to apply RMS Template to a Word Document without using the Interop Assembly ? RRS feed

  • Question

  • Hi,

       I am trying to create a server side application that will apply RMS Policy template to a Word document (or an Office Document in general) programmatically. Is there a way to achieve this without using the Word Interop(or Office Interop assemblies).

     

     

    Something like this works.

    object fileName = @"C:\Templates\Doc.docx";

                    doc 
    = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref isVisible);

                    
    string TemplateFile = @"C:\Templates\test.xml";

                    doc
    .Permission.ApplyPolicy(TemplateFile);

     

    But I would like to avoid using the interop. I have not found an alternative method.

     

    Thanks in Advance

    -Karthikeyan K

    Monday, September 10, 2012 5:06 AM

Answers

All replies

  • Hi,

       I am trying to create a server side application that will apply RMS Policy template to a Word document (or an Office Document in general) programmatically. Is there a way to achieve this without using the Word Interop(or Office Interop assemblies).

     

     

    Something like this works.

    object fileName = @"C:\Templates\Doc.docx";

                    doc 
    = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref isVisible);

                    
    string TemplateFile = @"C:\Templates\test.xml";

                    doc
    .Permission.ApplyPolicy(TemplateFile);

     

    But I would like to avoid using the interop. I have not found an alternative method.

     

    Thanks in Advance

    -Karthikeyan K

    Monday, September 10, 2012 5:07 AM
  • Hi Karthikeyan

    The only alternative to using the Interop is to work with the Open XML file directly. An Office Open XML file is a ZIP Package of XML files. The .Net Framework provides the System.IO.Packaging and OPen XML SDK to work with such files.

    My advice would be to inspect the content of a Word document with the permissions template applied - if you can. Some protection actions apply encryption, meaning the document cannot be accessed outside the actual Word application.

    IF it's possible to apply this to the file, it won't actually take effect until the file is opened in the Word UI.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, September 10, 2012 7:53 AM
    Moderator
  • Thanks Cindy,

        I am unable to inspect the document using the   OpenXMLSDKTool.exe after RMS has been applied as the file  is now encrypted.

    Please let me know if any other method exists to inspect the document.

    -Karthik

    Monday, September 10, 2012 10:44 AM
  • Hi Karthik

    In that case, there is no alternative than opening the document in the Word application and setting the permissions. This does make a certain amount of sense, as security settings that can be set by simply manipulating the file are of questionable value.


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, September 10, 2012 1:11 PM
    Moderator
  • Hi Cindy,

    I got a response from Martin on this thread http://social.technet.microsoft.com/Forums/en-US/rms/thread/9aee6027-ab97-4a5c-a77b-080b0f85288d . The suggestion was to use RMSBulk. This would mean starting a new process of RMSBulk from my application.

    Thanks

    -Karthik

    Thursday, September 13, 2012 2:08 PM
  • Hi Karthik

    Thanks for coming back and giving us an update :-) Yes, this looks like the right approach!


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, September 13, 2012 3:37 PM
    Moderator