1

我刚刚为一个严重依赖通过 Microsoft.Office.Interop.Powerpoint 自动化 Powerpoint 的客户端开发了一个自定义 VB.NET 应用程序。它在我的计算机上运行良好(运行 Windows 8、Office 2010 和 Visual Studio 2010),但无法在运行 Windows 7 和 Office 2007 的客户端计算机上安装。我认为问题是对“Microsoft Office”的引用14.0 对象库”和“Microsoft.Office.Interop.PowerPoint”版本 14.0,但我不知道如何更改对版本 12.0 的引用,这可能与 Office 2007 兼容。

我的 Visual Studio 中“参考”中唯一可用的版本是 14.0 版本。有什么方法可以获取旧版本,或者以其他方式使我的应用程序向后兼容?

我的客户在尝试安装时看到的错误是“应用程序要求首先在全局程序集缓存 (GAC) 中安装程序集 Microsoft.Interop.Powerpoint 版本 14.0.0.0。”

4

1 回答 1

0

我过去为 Word 做过这个,我怀疑它也适用于 PowerPoint。但这可能有点冒险,但这是 VB.Net 真正大放异彩的一个领域 :)

本质上,您使用调试版本进行开发并使用发布版本进行部署,并且对象使用不同的绑定类型。条件编译控制两种绑定方式的切换。

警告:我没有尝试过这个,但它应该非常接近你所追求的。

' Code for where you declare you your objects...
#If DEBUG Then
    ' Create the object for the dev environment using early binding
    Protected PowerpointApp As PowerPoint.Application = Nothing
    Protected PowerpointDoc As PowerPoint.Document = Nothing
#Else
    ' Create the object for the compiled application using late binding
    Protected PowerpointApp As Object = Nothing
    Protected PowerpointDoc As Object = Nothing
#End If


' Code for where you create your objects...
#If DEBUG Then
    ' Declare the object for the dev environment using early binding
    PowerpointApp = New PowerPoint.Application
#Else
    ' Declare the object for the compiled application using late binding
    PowerpointApp = CreateObject("POWERPOINT.APPLICATION")
#End If
' Use whichever method you want to open the document
PowerpointDoc = PowerpointApp.Documents.Open(etc, etc, etc, ...)
于 2012-11-08T01:38:32.103 回答