Table of contents
TOC
Collapse the table of content
Expand the table of content

Use Information Rights Management for Visio

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Learn to use Information Rights Management (IRM) with Visio documents.

Overview

You can use IRM support for Visio to programmatically:

  • Protect a Visio document from unauthorized access.

  • Manage individual and group access to an IRM-protected Visio document.

  • Change IRM permissions for a Visio document.

Requirements

To use IRM for Visio, you must install the following:

Protecting a Visio document

To protect the active document, use the Permission.Add method. To check whether a document is protected, use the Enabled property of the Permission object.

To remove protection from the active document, use the Permission.RemoveAll method, or use the UserPermission.Remove method for each user that has access.

Managing user access to an IRM-protected document

To give permissions on the active document to a specified user, use the Permission.Add method. The Permission property can be one or a combination of msoPermission constants from the following table.


msoPermission constantMeaning
msoPermissionViewRead access
msoPermissionReadRead access
msoPermissionEditEdit access
msoPermission SaveSave access
msoPermissionExtractCopy access, if the user also has read access
msoPermissionChangeAccess to view, edit, copy, and save but not to print the document. This is equivalent to msoPermissionView + msoPermissionEdit + msoPermissionSave + msoPermissionExtract.
msoPermissionPrintPrint access
msoPermissionObjModelA user can access the document programmatically. All users need this permission to work with a protected document or to check their permissions on the document.
msoPermissionFullControlFull control over the document. All permissions are enabled.

To check permissions for a user, use the UserPermission.Permission property.

To apply permissions by using an administrative policy, use the Permission.ApplyPolicy method. Use the PermissionFromPolicy, PolicyName, and PolicyDescription properties to return policy information.

To remove permissions for a specified user, use the UserPermission.Remove method. To remove all restrictions on the active document, use the Permission.RemoveAll method.

Accessing an IRM-protected document

To access a protected document, a user needs the following:

  • msoPermissionObjModel

  • The specific IRM permissions for any method or event that is used.

The following tables show the required permissions. Use the corresponding msoPermission constants from the previous section. For almost all APIs, the user needs the Edit ( msoPermissionEdit) permission. Note that if the user has Full Control ( msoPermissionFullControl), all APIs are enabled.

IRM permissions for Methods

MethodRequired permission
CopyRead and Copy
Copy ( Selection object)Read and Copy
Copy ( Shape object)Read and Copy
GetFilterCommandsRead
GetFilterObjectsRead
GetFilterSRCRead
GetFormulas[U]Read
GetNames[U]Read
GetPolylineDataRead
GetResultsRead
GetViewRectRead
Open ( Documents collection)Read
OpenExRead
PrintRead and Print
PrintTileRead and Print
For all other events not listed hereEdit

IRM permissions for Events

EventRequired permission
DocumentOpenedRead
WindowOpenedRead
WindowTurnedToPageRead
For all other events not listed hereEdit

Examples

Apply a user's permission example

This example gives a user a combination of Read and Edit permissions on the active document and sets an expiration date for these permissions.

Dim objPermission As Office.Permission
Dim objUserPerm As Office.UserPermission

Set objPermission = ActiveDocument.Permission
Set objUserPerm = objPermission.Add( _
"<user>@<domain>.com", _
msoPermissionRead + msoPermissionEdit, #12/31/2016#)
MsgBox "Permissions added for " &; _
objUserPerm.UserId, _
vbInformation + vbOKOnly, _
"Permissions Added"
Set objUserPerm = Nothing

Apply administrative permission policy example

This example checks whether the active document is protected and, if it is not, protects the document and applies an administrative permission policy.

Dim irmPermission As Office.Permission 
 Set irmPermission = ActiveDocument.Permission 
 Dim strIRMInfo As String 
 Select Case irmPermission.Enabled 
 Case True 
 strIRMInfo = "Permissions are already restricted on this document." 
 Case False 
 With irmPermission 
 .Enabled = True 
 .ApplyPolicy ("\\server\share\permissionpolicy.xml") 
 End With 
 strIRMInfo = "Permissions are now restricted on this document " &; _ 
 vbCrLf &; _ 
 " and the permission policy has been applied." 
 End Select 
 MsgBox strIRMInfo, vbInformation + vbOKOnly, "IRM Information" 
 Set irmPermission = Nothing

List permitted users example

This example checks whether the active document is protected and, if it is, lists users and their assigned permissions.

Dim irmPermission As Office.Permission 
 Dim irmUserPerm As Office.UserPermission 
 Dim strIRMInfo As String 
 Set irmPermission = ActiveDocument.Permission 
 If irmPermission.Enabled Then 
 For Each irmUserPerm In irmPermission 
 strIRMInfo = strIRMInfo &; irmUserPerm.UserId &; vbCrLf &; _ 
 " - Permissions: " &; irmUserPerm.Permission &; vbCrLf &; _ 
 " - Expiration Date: " &; irmUserPerm.ExpirationDate &; vbCrLf 
 Next 
 MsgBox strIRMInfo, _ 
 vbInformation + vbOKOnly, "IRM Information" 
 Else 
 MsgBox "This document is not restricted.", _ 
 vbInformation + vbOKOnly, "IRM Information" 
 End If 
 Set irmUserPerm = Nothing 
 Set irmPermission = Nothing

Remove a user's permissions example

This example removes the second user's permissions on the active document from the document's Permission collection.

Dim irmPermission As Office.Permission 
 Dim irmUserPerm As Office.UserPermission 
 Set irmPermission = ActiveDocument.Permission 
 Set irmUserPerm = irmPermission.Item(2) 
 irmUserPerm.Remove 
 MsgBox "Permission removed.", _ 
 vbInformation + vbOKOnly, "IRM Information" 
 Set irmUserPerm = Nothing 
 Set irmPermission = Nothing
© 2018 Microsoft