none
How to set document Permission (RMS) RRS feed

  • Question

  • Hi,

    Using Office you can set permissions on document from ribbon > File > Info > Protect Document >restrict Access. How I can do that from code?

    In Outlook it is quit simple you can set MailItem.PermissionTemplateGuid

    Word doesn't have such property it has Permission property object but i didn't found  any way to set the permission from policy. I am using Office 2013.

    Any idea?

    Monday, August 31, 2015 2:31 PM

All replies

  • >>>Using Office you can set permissions on document from ribbon > File > Info > Protect Document >restrict Access. How I can do that from code?

    As far as I searching, I think you could not do that.

    Information Rights Management (IRM) allows individuals and administrators to set access permissions to documents, workbooks, presentations, and e-mail messages.

    This helps prevent sensitive information from being printed, forwarded, or copied by unauthorized people.

    After permission for a file is restricted by using IRM, the access and usage restrictions are enforced even if the file reaches unintended recipients.

    This is because the access permissions are stored in the document, workbook, presentation, or e-mail message itself. And these must be authenticated against the server.

    For more information, click here to refer about About restricting access with Information Rights Management

    If you want to add protection to Microsoft Office Word documents to prevent users from making any edits to the document,

    you could refer to How to: Programmatically Protect Documents and Parts of Documents

    https://msdn.microsoft.com/en-us/library/ms178793.aspx

    Tuesday, September 1, 2015 7:22 AM
  • Thx David, I know what RMS is but I don't know how to use it programically. The protected mechanizm in Office documents is totally diferent thing, I know how it works and how to use it but this is not my question.

    So I still looking for answer how to use RMS from VSTO. As I mentioned the API for Outlook is quite simply but for Word is not.


    Tuesday, September 8, 2015 7:59 AM
  • Hi Konrad

    See if the Permission object (as in Document.Permission) is what you're looking for. Since my machine doesn't have access to a server that can handle IRM I don't see the "restrict access" menu selection. But the Help topic sounds like what you're asking about...


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, September 8, 2015 5:27 PM
    Moderator
  • Thx David, I know what RMS is but I don't know how to use it programically. The protected mechanizm in Office documents is totally diferent thing, I know how it works and how to use it but this is not my question.

    So I still looking for answer how to use RMS from VSTO. As I mentioned the API for Outlook is quite simply but for Word is not.


    Hi Konrad, did you succeed on your requirement? im facing the same req.

    Could you please share any info you got?

    Thanks in advance

    Thursday, June 9, 2016 12:07 PM
  • Microsoft.Office.Interop.Word.Application application = null;
    application = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application") as Microsoft.Office.Interop.Word.Application;
    Microsoft.Office.Interop.Word.Document document = application.Documents.Open(FileName: @"D:\IRM3.docx", ReadOnly: false);
    DateTime dtExpirationDate = DateTime.Today.AddMinutes(3);
    document.Permission.Enabled = true;
    document.Permission.Add(null, Microsoft.Office.Core.MsoPermission.msoPermissionFullControl, dtExpirationDate);
    document.Close(true);   
    Thursday, November 14, 2019 9:13 AM