14

我希望能够通过按下 Windows 窗体中的按钮来推进 Powerpoint 演示。这是我从http://bytes.com/topic/c-sharp/answers/272940-open-powerpoint-presentation-c-window-form找到的一些代码,它打开了一个 Powerpoint 演示幻灯片:

Microsoft.Office.Interop.PowerPoint.Application oPPT;
Microsoft.Office.Interop.PowerPoint.Presentations objPresSet;
Microsoft.Office.Interop.PowerPoint.Presentation objPres;

//the location of your powerpoint presentation
string strPres = @"filepath";

//Create an instance of PowerPoint.
oPPT = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();

// Show PowerPoint to the user.
oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;

objPresSet = oPPT.Presentations;

//open the presentation
objPres = objPresSet.Open(strPres, MsoTriState.msoFalse,
MsoTriState.msoTrue, MsoTriState.msoTrue);

objPres.SlideShowSettings.Run();

但是,我还没有找到任何可以通过幻灯片推进的方法。有任何想法吗?

(我真正想做的是使用 WiiRemote 推进幻灯片,用于学生项目)。

4

4 回答 4

10

以编程方式推进的方法是“SlideShowWindow.View.Next”。您也可以使用“SlideShowWindow.View.Previous”向后退。

于 2009-09-25T06:48:05.830 回答
3

看起来有一个叫做 GotoSlide 的方法可以工作,只需要再挖掘一点!例如:

int i = 0;
while (true)
{
    i++;
    objPres.SlideShowWindow.View.GotoSlide(i, MsoTriState.msoFalse);
    System.Threading.Thread.Sleep(5000);
}
于 2009-09-23T00:52:50.397 回答
1

我认为您可以这样做以一次运行它们,例如:

oSettings = objPres.SlideShowSettings
oSettings.StartingSlide = 3
oSettings.EndingSlide = 3

oSettings.Run()
Do While oApp.SlideShowWindows.Count >= 1
    System.Windows.Forms.Application.DoEvents()
Loop
于 2009-09-23T00:37:07.013 回答
0

您可能已经得到了问题的答案,但是对于将面临同样问题的人,我将发送一个开源 C# 代码的链接,该代码可以顺利处理这种情况。

https://code.msdn.microsoft.com/office/How-to-Automate-control-23cd2a8f

下载zip文件,里面有一个完美控制power point幻灯片的ac#项目

祝各位。

于 2015-03-26T09:24:43.027 回答