2012-11-07 27 views
1

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

唯一可用的版本是”参考“在我的Visual Studio是14.0的。有没有办法获得旧版本,否则使我的应用程序向后兼容?

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

+0

你将不得不从我认为的源代码中引用2007版的dll。 – urlreader

回答

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, ...)