Office Pia-based applicationsProgramThere are several ways to run smoothly on customers' computers:
Method 1: Let the customer install ". Net programmable support" (. NET programmability Support) when installing the office)
Read, not explained:
Method 2: Ask the customer to install office Pia
For example, for Office 2007 Pia, search for "Office 2007 Pia" on the Microsoft website download channel and obtain the following information:
2007 Microsoft Office system update: redistributable primary InterOP assemblies
Http://www.microsoft.com/download/en/details.aspx? Id = 18346
However, the above two methods may cause poor user experience. I want to introduce method 3.
Method 3: deploy necessary DLL files to the program execution directory
First, after installing office Pia on the development machine, we need to know which DLL we all need. Not all DLL files are required.
In my previous example 《Office Pia:CodeExample: Excel app class for generating Excel filesFor example:
The only dll I need is:
- Microsoft. Office. InterOP. Excel. dll
- Microsoft. VBE. InterOP. dll
- Office. dll
Add references to the three DLL files in the Visual Studio Project (that is, the three references marked with red lines ):
Note: If you only Add a reference to Microsoft. Office. InterOP. Excel. dll, You can compile the program successfully. However, to copy the remaining two DLL files to the program execution directory, you must add all the three references.
Then, set the copy local attribute of the three references to true:
In this way, after your program is compiled, these three DLL files are also copied to the program running directory.
Of course, there areMethod 4: deploy related DLL through installation project. I will not go into details.
References: