我在过去为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, ...)
你将不得不从我认为的源代码中引用2007版的dll。 – urlreader