开发者

How to activate opened presentation?

Hi Could some one help me for this problem: How to activate a presentation window by using its name?

  foreach (PPT.Presentation ppt in ppApp.Presentations)
    {
       if (ppt.开发者_StackOverflowName == strTargetFileName)
            {
               //Then activate this ppt. How to do this?

                        }


You can launch a PowerPoint with Process.Start:

Process.Start(@"c:\users\foo\Documents\Bar.ppt");

If you need to actually launch it in slideshow mode, you can do:

Process.Start("powerpnt", "/s \"C:\\Users\\Foo\\Documents\\Bar.ppt\"");


You should find window handle first with FindWindow function and when activate it with SetForegroundWindow function. Check this page, sample code there performs actually what you are looking for


first add a reference ( rigth click solution explorer to Microsoft PowerPoint XX Object)

   using MSPPOINT = Microsoft.Office.Interop.PowerPoint;

define a instance of the object

    MSPPOINT._Application pwpApp = new MSPPOINT.Application();
    MSPPOINT._Presentation pwpDoc = null;

    pwpApp.Activate();
    pwpDoc = pwpApp.Presentations.Open(@"D:\Temp\Document.pptx", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
//enter code here

and do something with him.. Good Luck !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜