Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VB.NET中的ActivePresentation_Vb.net - Fatal编程技术网

VB.NET中的ActivePresentation

VB.NET中的ActivePresentation,vb.net,Vb.net,在VBA中,我们有ActivePresentation。我想知道如何在VB.NET中实现同样的功能 我有以下代码 Dim oApp As PowerPoint.Application Dim oPres As PowerPoint.Presentation = oApp.ActivePresentation 我的问题是如何在VB.NET中声明或使用ActivePresentation 有谁能帮助我如何在VB.NET中使用ActivePresentation。首先,您需要将oApp声明为New应

在VBA中,我们有
ActivePresentation
。我想知道如何在VB.NET中实现同样的功能

我有以下代码

Dim oApp As PowerPoint.Application
Dim oPres As PowerPoint.Presentation = oApp.ActivePresentation
我的问题是如何在VB.NET中声明或使用ActivePresentation


有谁能帮助我如何在VB.NET中使用
ActivePresentation

首先,您需要将
oApp
声明为
New
应用程序,以创建PowerPoint的新实例。
这是必需的,因为您的代码不像VBA那样在PowerPoint“内部”运行

之后,您需要打开一个演示文稿(或创建一个新的演示文稿),该演示文稿可通过
ActivePresentation
访问

Dim oApp As New PowerPoint.Application
oApp.Presentations.Open("C:\test.pptx")
Dim oPres As PowerPoint.Presentation = oApp.ActivePresentation
您还可以同时打开多个演示文稿,可以通过名称对其进行寻址:

Dim oPres As PowerPoint.Presentation = oApp.Presentations("test.pptx")
…或索引(以1开头):


我的问题可能重复的地方实际上是我们如何在VB.neta中声明或使用ActivePresentation尽管您删除了收到NullReferenceException的事实,但这实际上是您的问题。请参阅建议的副本。您已经正确声明了ActivePresentation。如果,在解决NullReferenceException之后。你想要一个关于如何使用ActicePresentation的教程,这个问题太宽泛了。正是我想要的。非常感谢。它就像一个符咒。感谢您的解释,我无法在vb.net中找到活动演示文稿。
Dim oPres As PowerPoint.Presentation = oApp.Presentations(1)