(Article-Harry Miller: http://blogs.msdn.com/vsto/archive/2008/07/18/removing-customization-code-before-e-mailing-a-document.aspx)
Create vsto custom for a word/Excel documentCodeLater, subsequent copies of this document will also be associated with the code, even if you change the document name when you "Save as", the Association still exists. Every time the document is opened, it will try to find the associated vsto code and start running. Question: What if we need to send documents to external personnel (such as customers and suppliers )? They do not have the permission to access our internal network, and the document cannot find the associated code, so a nasty error dialog box will pop up, tell the confused user "the user cannot find or load the customProgramFor common office users, this is the same information as tianshu.
So sometimes we need to remove the association between the document and the vsto code before distributing the document.
One way is to manually delete the "_ assemblyname" and "_ assemblylocation" attributes in the "properties-Advanced properties-custom" project of the document.
Another method is to program and use the "serverdocument. removecustomization ()" method to remove the association between documents and code. The sample program in the vsto document contains the relevant code for reference.
Related Resources:
Serverdocument. removecustomization method (2007 Office System)
Serverdocument. removecustomization method (2003 Office System)
Serverdocument sample code
Use the serverdocument class to manage documents on the server