Wix:如何将.XLL文件复制到依赖于Excel版本的Excel常用LIBRARY文件夹中?

Tec*_*ach 2 excel installer windows-installer wix

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

我现在知道如何将我的文件放在当前用户的Excel插件库文件夹中,该文件夹多年来一直是%AppData%\ Microsoft\AddIns和o/s版本.

但是,我还需要将几个.XLL文件复制(但激活)到Excel的依赖于Excel版本的公共/共享插件库文件夹.例如..\Office 11\LIBRARY,..\Office 14\LIBRARY等

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

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

在WiX中,我是否被迫创建一个自定义操作项目来访问Excel对象以读取库路径?

谢谢你的时间.

bra*_*drg 5

没有自定义操作就可以解决这个问题,尽管如果你想支持很多不同版本的办公室,这个解决方案可能会变得非常冗长.一般的想法是使用a <RegistrySearch.../>将属性设置为特定版本的办公室的位置.然后将该属性用作目录位置和组件条件.

一个轻微的复杂性:用作Directory元素的Directory属性的属性应该是注册表搜索找到的属性的副本.如果我们尝试使用注册表搜索返回的相同属性,则Directory元素会将该属性设置为已解析的目录位置,这将将条件设置为true并始终安装该组件.

<RegistrySearch.../>为Excel 2010:

<!-- 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"/>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

您需要为支持的每个版本的办公室重复上述块.

Excel 2007

要支持Excel 2007,您可以将上例中的引用更改为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>
Run Code Online (Sandbox Code Playgroud)

64位Excel 2010

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

<RegistrySearch.../>64位Excel 2010中:

<!-- 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"/>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

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