user734178
user734178

Reputation: 43

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.Name == strTargetFileName)
            {
               //Then activate this ppt. How to do this?

                        }

Upvotes: 0

Views: 1500

Answers (3)

Sk.
Sk.

Reputation: 460

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 !

Upvotes: 0

Anton Semenov
Anton Semenov

Reputation: 6347

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

Upvotes: 1

Mark Heath
Mark Heath

Reputation: 49522

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\"");

Upvotes: 1

Related Questions