Udostępnij za pośrednictwem


How to: Permit Code to Run Behind Documents with Restricted Permissions

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • Microsoft Office 2003

  • 2007 Microsoft Office system

For more information, see Features Available by Application and Project Type.

You can use the Information Rights Management (IRM) feature of Microsoft Office to restrict permissions to a document or workbook. By default, the code behind a restricted Microsoft Office Word document or Microsoft Office Excel workbook is not permitted to run. You can change the default so that your managed code extensions can access the object model, and your solution will work.

You must be the author of the document or workbook or have Full Control access to be able to change the permission settings.

To permit code to run behind documents with restricted permissions in Microsoft Office 2003

  1. Open the document or workbook in Word or Excel.

  2. On the File menu, point to Permission, and then click Do Not Distribute.

  3. In the Permission dialog box, click More Options.

  4. Under Additional permissions for users, select Access content programmatically.

Word or Excel will permit programmatic access to the object model.

To permit code to run behind documents with restricted permissions in the 2007 Microsoft Office system

  1. Open the document or workbook in Word or Excel.

  2. Click the Microsoft Office Button, point to Prepare, point to Restrict Permission, and then click Restricted Access.

    Note

    On first use, you are prompted to install the Windows Rights Management client. After you install the client, you might need to repeat the steps.

  3. In the Permission dialog box, select Restrict permission to this document, and then click More Options.

  4. Under Additional permissions for users, select Access content programmatically.

Word or Excel will permit programmatic access to the object model.

See Also

Tasks

How to: Deploy Office Solutions (2003 System)

Concepts

Information Rights Management and Managed Code Extensions Overview

Document Protection in Document-Level Solutions

Password Protection on Office Documents

Creating Office Solutions in Visual Studio

Secure Deployment (2003 System)

Deploying Office Solutions (2003 System)