Wix:如何将.XLL文件复制到Excel的Excel版本相关的常见LIBRARY文件夹?

我是WiX新手,尝试创build一个安装程序来分发我创build的一些Excel加载项(.XLL文件)。

我现在知道如何将我的文件放在当前用户的Excel加载项库文件夹中,这个文件夹已经是%AppData%\ Microsoft \ AddIns许多年了,现在还是o / s版本。

不过,我还需要复制(但激活)一些.XLL文件到Excel的Excel / Common共享插件库文件夹中,这是依赖于Excel版本的。 例如.. \ Office 11 \ LIBRARY,.. \ Office 14 \ LIBRARY等

如何编写我的脚本,以确保安装程序将正确地将.XLL文件复制到公用/共享“Office XX \ LIBRARY”文件夹,而不pipe安装的Excel版本是什么?

当我使用InstallShield时,我依赖于可以直接从IS脚本访问的Excel自动化对象中的LibraryPath()函数。

在WiX中,我不得不创build一个自定义操作项目来访问Excel对象,以便读取库path?

谢谢你的时间。

如果你想支持很多不同版本的办公室,这个解决scheme可能会非常冗长。 总的想法是使用<RegistrySearch.../>将属性设置为特定版本Office的位置。 然后使用该属性作为组件的目录位置和条件。

一个轻微的复杂性:用作Directory元素的Directory属性的属性应该是registrysearchfind的属性的副本。 如果我们尝试使用registrysearch返回的相同属性,则Directory元素将将该属性设置为已parsing的目录位置,该位置会将条件设置为true,然后安装该组件。

Excel 2010的<RegistrySearch.../>

 <!-- Search for Excel 2010 --> <Property Id="OFFICE14LOCATION"> <RegistrySearch Id="Office14Location" Root="HKLM" Key="SOFTWARE\Microsoft\Office\14.0\Excel\InstallRoot" Name="Path" Type="raw"/> </Property> <!-- Make a copy of the property for the directory reference --> <SetProperty Id="Office14DirectoryPath" Value="[OFFICE14LOCATION]" Before="CostFinalize"/> 

Excel 2010的组件部分:

 <!-- Conditionally install MyAddIn.xll to the Office14\Library directory Remember to reference Office14Library in a <Feature> --> <DirectoryRef Id="Office14Library"> <Component Id="Office14AddIn" Guid="-- your GUID --"> <Condition>OFFICE14LOCATION</Condition> <File Id="Office14AddIn" Name="MyAddIn.xll" Source="MyAddIn.xll" /> </Component> </DirectoryRef> 

Excel 2010的目录部分:

 <!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> --> <Directory Id="Office14DirectoryPath" Name="Office14"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning --> <Directory Id="Office14Library" Name="Library"/> </Directory> 

您需要重复上述各个版本的办公室支持的块。

Excel 2007

为了支持Excel 2007,你可以把上面的例子中的引用14更改为12.例如:

 <!-- Search for Excel 2007--> <Property Id="OFFICE12LOCATION"> <RegistrySearch Id="Office12Location" Root="HKLM" Key="SOFTWARE\Microsoft\Office\12.0\Excel\InstallRoot" Name="Path" Type="raw"/> </Property> <!-- Make a copy of the property for the directory reference --> <SetProperty Id="Office12DirectoryPath" Value="[OFFICE12LOCATION]" Before="CostFinalize"/> <!-- Conditionally install MyAddIn.xll to the Office12\Library directory Remember to reference Office12Library in a <Feature> --> <DirectoryRef Id="Office12Library"> <Component Id="Office12AddIn" Guid="-- your GUID --"> <Condition>OFFICE12LOCATION</Condition> <File Id="Office12AddIn" Name="MyAddIn.xll" Source="MyAddIn.xll" /> </Component> </DirectoryRef> <!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> --> <Directory Id="Office12DirectoryPath" Name="Office12"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning --> <Directory Id="Office12Library" Name="Library"/> </Directory> 

64位Excel 2010

该解决scheme还可以扩展为支持64位版本的Excel 2010:

64位Excel 2010的<RegistrySearch.../>

 <!-- Search for 64 bit Excel 2010 --> <Property Id="OFFICE14LOCATIONX64"> <RegistrySearch Id="Office14LocationX64" Root="HKLM" Key="SOFTWARE\Microsoft\Office\14.0\Excel\InstallRoot" Name="Path" Win64="yes" Type="raw"/> </Property> <!-- Make a copy of the property for the directory reference --> <SetProperty Id="Office14DirectoryPathX64" Value="[OFFICE14LOCATIONX64]" Before="CostFinalize"/> 

64位Excel 2010的组件部分:

 <!-- Conditionally install MyAddIn.xll to the Office14\Library directory Remember to reference Office14Library in a <Feature> --> <DirectoryRef Id="Office14LibraryX64"> <Component Id="Office14AddInX64" Win64="yes" Guid="-- your GUID --"> <Condition>OFFICE14LOCATIONX64</Condition> <File Id="Office14AddInX64" Name="MyAddIn.xll" Source="MyAddIn.xll" /> </Component> </DirectoryRef> 

64位Excel 2010的目录部分:

 <!-- Note: Include this as a child of <Directory Id="TARGETDIR" ..> --> <Directory Id="Office14DirectoryPathX64" Name="Office14X64"> <!-- Note: The Name attribute is redundant but needed to avoid ICE30 warning --> <Directory Id="Office14LibraryX64" Name="Library"/> </Directory> 

有用的参考资料: 如何检测安装的MS-Office版本? 如何使用Wix将一组文件复制到多个位置?