2011-01-25 50 views
0

我想連續循環播放一些ppt文件,但是當第一個文件到達最後一張幻燈片後打開新文件時,會打開一個新的PowerPoint窗口並啓動幻燈片。 我該如何解決這個問題?連續循環顯示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; 
    } 
+0

@ user589216:只想跟進以查看下方是否回答您的問題 – 2011-04-05 20:51:17

回答

1

不幸的是,你不能用多個PowerPoint文件做到這一點。在PowerPoint 2010之前,您不能同時運行多個PPT(即使使用PP2010,也不會這麼做)。所以通過關閉一個並打開一個新的運行窗口,您將失去主窗口。

您可以創建多個PowerPoint實例,將它們設置爲可見/隱藏,然後當一個幻燈片結束時,以編程方式取消隱藏下一個幻燈片並顯示它運行,但這會遭受與您已有的相同閃爍問題。

你可以做的最好的辦法是讀取目錄中的所有ppts,按照你需要的順序將它們全部合併到一個新的卡組中(然後指定佈局等),然後在kiosk-loop中運行該卡組。

相關問題