PRB: Office 2003 Managed Code Extension Does Not Load (824015)



The information in this article applies to:

  • Microsoft Office Excel 2003
  • Microsoft Office Word 2003
  • Microsoft Visual Studio Tools for the Microsoft Office System version 2003

SYMPTOMS

When you open a Microsoft Office Excel workbook or a Microsoft Office Word document, the managed code extension does not load. However, you do not receive an error message.

CAUSE

The _AssemblyLocation0 property and the _AssemblyName0 property in the workbook or the document provide details to the managed code loader about a managed code extension. If you encrypt the document properties, and then you change the value of the _AssemblyLocation0 property or the _AssemblyName0 property later by using any one of the following methods, the managed code extension will not load:
  • Use the build process in Microsoft Visual Studio .NET to build your managed code extension.

    -or-
  • Use the Persistence Control that is included with Microsoft Visual Studio Tools for the Microsoft Office System.

    -or-
  • Use the Properties window in Microsoft Windows Explorer.

RESOLUTION

To resolve this problem, decrypt the document properties of the workbook or the document before you change the value of the _AssemblyLocation0 property or the _AssemblyName0 property. Re-encrypt the document properties after you making your changes. To do this, follow the steps under "Resolution" in the "More Information" section of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Excel workbook that has encrypted document properties:
    1. Start Microsoft Office Excel 2003, and then create a new workbook.
    2. On the Tools menu, click Options.
    3. In the Options dialog box, click the Security tab.
    4. Under File encryption and settings, click Advanced.
    5. In the Choose an encryption type list box, click RC4, Microsoft Base Cryptographic Provider v1.0.
    6. Click to select the check box for Encrypt document properties, and then click OK.
    7. In the Password to open text box, type a password. Click OK. Type the password again when you are prompted to do so.
    8. Save the workbook as C:\Encrypt.xls.
    9. Close the workbook, and then quit Excel.
  2. Create a new Excel workbook project:
    1. Start Visual Studio .NET 2003.
    2. On the File menu, point to New, and then click Project.
    3. Under Project Types, expand Microsoft Office System Projects, and then click Visual Basic Projects.
    4. Under Templates, click Excel Workbook. Name the new project EncryptedBook, and then click OK.

      The Microsoft Office Project Wizard starts.
    5. In the Microsoft Office Project Wizard, click Use existing document, locate C:\Encrypt.xls, and then click Finish.
  3. Add the following code to the ThisWorkbook_Open procedure:
    MessageBox.Show("ThisWorkbook_Open")
  4. Press F5 to build and then run the project.

    The workbook opens. However, the message box does not appear.

Resolution

  1. Open the C:\Encrypt.xls file in Excel.
  2. Remove encryption from the document properties:
    1. On the Tools menu, click Options.
    2. In the Options dialog box, click the Security tab.
    3. Under File encryption and settings, click Advanced.
    4. In the Encryption Type dialog box, click to clear the check box for Encrypt document properties, and then click OK.
    5. In the Options dialog box, click OK.
  3. Save the workbook, and then quit Excel.
  4. In Visual Studio .NET, open the EncryptedBook project.
  5. In Solution Explorer, click the project.
  6. On the View menu, click Properties Window.
  7. In Properties, change the value of the Assembly Link Location property to ..\EncryptedBook_bin, and then change the value of the Copy Assembly property to True.
  8. Press F5 to build and then run the project.

    The workbook opens and the message box appears.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site: For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290112 General Information about Microsoft Office Encryption


Modification Type:MinorLast Reviewed:2/3/2006
Keywords:kbprb kbPIA KB824015 kbAudDeveloper