How to: Open Office Solutions without Running Code
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
Microsoft Office version
For more information, see Features Available by Application and Project Type. |
A Microsoft Office 2003 solution created with managed code extensions runs even if the Security setting in the end user's Office application is set to High. This is because .NET assembly code security is managed by the Microsoft .NET Framework, not by Microsoft Office Word 2003 or Microsoft Office Excel 2003.
However, there are times when you might want to open a document without running the code. For example, code that runs when the document opens might alter the contents, but you want to update the way the document looks before the code changes it. Or you might want to send the document with certain information in it to someone, and you do not want the code to run and possibly alter the contents.
There are several ways to open a document or workbook that contains managed code extensions without running the assembly code.
To bypass the assembly by using the SHIFT key
Open documents and workbooks from the File menu while holding down the SHIFT key to prevent Word and Excel from raising initialization events while the document is opening.
Note
If you open a document or workbook from the Getting Started task pane, holding down SHIFT does not bypass the code. Also, holding down SHIFT does not prevent events from being raised after the document is open.
This method is useful if you want to open a document to make changes without the code running and altering the document first.
To bypass the assembly by removing full trust
You can remove full trust from the assembly in your security policy. This results in an error being raised every time the Office document is opened. For more information, see How to: Remove Permissions from Folders and Assemblies (2003 System).
This method is useful if you want to stop the solution from running on your computer, but you do not want to stop other users from running the solution at the same time.
To bypass an assembly by renaming or removing it
If you have the necessary permissions on the computer where the assembly is located, you can rename or remove the assembly so the document or workbook cannot find it. This results in an error being raised every time the Office document is opened.
If the solution is used by multiple people, this method prevents the solution from running for all of them. This can be useful if a problem is found in the code or a referenced server and you want to stop all users from executing it.
See Also
Concepts
Assemblies in Office Solutions Overview
Secure Deployment (2003 System)