Distribute .NET Applications That Use Excel
Use the Visual Studio .NET setup and deployment project to create an installation program for applications that use Excel as a component. (See "Distribute .NET Components,” earlier in this chapter, for a walk-through of using the Setup Wizard.)
The .NET setup tools detect the .NET Framework and Excel PIAs as dependencies of any application that uses Excel as a component and includes those files with the installation. However, the setup tools do not automatically check for the installation of Microsoft Excel, or any other Microsoft Office product. You can add required products as a launch condition in the setup project for your application.
PIAs are available for Excel 2002 and later. However, you can use Visual Studio .NET type library import tools to create interop assemblies for earlier versions of Excel (they won’t work as well as the PIAs, but they will work). All interop assemblies are tied to a specific version of Excel, so you should check that the required version of Excel is installed on the user’s computer before installing your application and each time your application starts. You can use the following code to detect which version of Excel is installed:
' Uses the following Imports statement for RegistryKey classes: Imports Microsoft.Win32 Function GetExcelVer( ) As String ' Define the RegistryKey objects. Dim regRoot As RegistryKey, regExcel As RegistryKey, ver As String ' Get root registry entry. regRoot = Microsoft.Win32.Registry.ClassesRoot ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access