【问题标题】:Make VB.NET app compatible with Office 2007使 VB.NET 应用程序与 Office 2007 兼容
【发布时间】:2012-11-07 19:25:37
【问题描述】:

我刚刚为一个严重依赖通过 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。”

【问题讨论】:

  • 你得从我认为的源代码中引用2007版本的dll。

标签: vb.net visual-studio-2010


【解决方案1】:

我过去曾为 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, ...)

【讨论】:

    猜你喜欢
    • 2020-03-26
    • 2011-03-27
    • 1970-01-01
    • 2011-04-25
    • 2011-11-06
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多