C # Powerpoint SlideShowEnd problèmes
-
20-08-2019 - |
Question
Je crée une application C # qui lit un diaporama PowerPoint. Une fois le diaporama terminé, je souhaite arrêter PowerPoint et revenir à mon programme. Le problème que je rencontre est que je dois cliquer sur la fin du diaporama pour retourner à mon programme ...
Existe-t-il un moyen que je puisse désactiver pour attendre un clic?
private void ShowPresentation()
{
String strPresentation, strPic;
strPresentation = Application.StartupPath + "\\testje.ppt";
bool bAssistantOn;
//PowerPoint.Application objApp;
PowerPoint.Presentations objPresSet;
PowerPoint._Presentation objPres;
PowerPoint.Slides objSlides;
PowerPoint._Slide objSlide;
PowerPoint.TextRange objTextRng;
PowerPoint.Shapes objShapes;
PowerPoint.Shape objShape;
PowerPoint.SlideShowWindows objSSWs;
PowerPoint.SlideShowTransition objSST;
PowerPoint.SlideShowSettings objSSS;
PowerPoint.SlideRange objSldRng;
Graph.Chart objChart;
//Create a new presentation based on a template.
objApp = new PowerPoint.Application();
objApp.SlideShowBegin += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowBeginEventHandler(powerpnt_SlideShowBegin);
objApp.SlideShowEnd += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(powerpnt_SlideShowEnd);
objApp.SlideShowNextSlide += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowNextSlideEventHandler(powerpnt_SlideShowNextSlide);
objApp.Visible = MsoTriState.msoTrue;
objPresSet = objApp.Presentations;
objPres = objPresSet.Open(strPresentation, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
objSlides = objPres.Slides;
//Prevent Office Assistant from displaying alert messages:
bAssistantOn = objApp.Assistant.On;
objApp.Assistant.On = false;
//Run the Slide show from slides 1 thru 3.
objSSS = objPres.SlideShowSettings;
objSSS.StartingSlide = 1;
objSSS.EndingSlide = objSlides.Count;
objSSS.Run();
}
private void powerpnt_SlideShowEnd(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
{
objApp.Quit();
}
En un mot, SlideShowEnd ne se déclenche que lorsque la dernière diapositive a été lue et que j'ai cliqué sur la présentation. Je veux que SlideShowEnd soit activé lorsque la dernière diapositive aura été lue ...
La solution
Dans les paramètres PowerPoint, il existe une option: Terminer avec le côté noir. Vous pouvez essayer de voir si cela existe dans le COM et de l'utiliser.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow