【问题标题】:C# - Show PowerPoint Presentations continousC# - 连续显示 PowerPoint 演示文稿
【发布时间】:2011-01-25 15:58:53
【问题描述】:

我想连续循环播放一些ppt 文件,但是当我在第一个文件到达最后一张幻灯片后打开一个新文件时,会打开一个新的 PowerPoint 窗口并启动幻灯片。 我该如何解决这个问题?

        public Microsoft.Office.Interop.PowerPoint.SlideShowWindow startppt(string pptDatei)
    {
        WatchingLabel.Text = "Präsentation läuft...";
        started = true;
        ende = false;
        objPres = ppApp.Presentations.Open(pptDatei, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue);

        objPres.SlideShowSettings.ShowWithAnimation = Microsoft.Office.Core.MsoTriState.msoTrue;
        presWin = objPres.SlideShowSettings.Run();

        return presWin;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        WatchingLabel.Text = "Watching...";

        if (System.IO.Directory.Exists(ordner))
        {
            pptDatei.Clear();
            pptDatei.AddRange(System.IO.Directory.GetFiles(ordner, "*.ppt"));

            if (started == true && presWin.View.State == Microsoft.Office.Interop.PowerPoint.PpSlideShowState.ppSlideShowDone)
            {
                objPres.Close();
                ende = true;
                started = false;
            }

            if (pptDatei.Count > 0 && ende && started == false)
            {
                if (index < pptDatei.Count)
                {
                    startppt(pptDatei[index]);
                    index += 1;
                }
                else
                {
                    index = 0;
                }
            }
            else if (pptDatei.Count > 0 && ende == false && started == true)
            {
                presWin.View.Next();
            }

        }
    }

    public void ppApp_PresentationClose(Microsoft.Office.Interop.PowerPoint.Presentation Pres) 
    {
        pptDatei = new List<string>();
        started = false;
        ende = true;
        WatchingLabel.Text = "Präsentation beenden...";
    }

    public void ppApp_SlideShowEnd(Microsoft.Office.Interop.PowerPoint.Presentation Pres) 
    {
        ende = true;
        started = false;
    }

【问题讨论】:

  • @user589216: 只是想跟进看看以下是否回答了您的问题

标签: c# .net ms-office powerpoint


【解决方案1】:

很遗憾,不,您不能对多个 PowerPoint 文件执行此操作。在 PowerPoint 2010 之前,您不能同时运行多个 PPT(即使使用 PP2010,这样做也很困难)。因此,关闭一个并打开一个新的运行,您将失去主运行窗口。

您可以创建多个 PowerPoint 实例,将它们设置为可见/隐藏,然后当一个幻灯片结束时,以编程方式取消隐藏下一个并显示它以运行,但这会遇到与您已有的相同的闪烁问题。

您可以做的最好的事情是阅读目录中的所有 ppts,按照您需要的顺序将它们全部合并到一个新的卡片组中(并指定布局等),然后在信息亭循环中运行该单一卡片组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-26
    • 2016-05-10
    • 1970-01-01
    • 2020-03-05
    • 2017-07-03
    • 2010-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多