Opening PowerPoint using Visual studio C# script for Windows 8 RRS feed

  • General discussion

  • Hi EveryOne,

    I was trying to write up script for opening and play the power-point using C#  it works with Visual studio 2010 (windows 7) but when i tried with Visual Studio 2013 (Windows 8.1) the code not working. always getting exception.

    anyone has the working code for opening ppt app ? using visual studio 2013very urgent .. please help me in this


    Ashok r

    Monday, June 16, 2014 5:32 AM

All replies

  • well the frameworks for store apps (are you writing a store app? doesn't get me very clear) is different then store apps. can you show some code? You should Launcher.LaunchFileAsync to open files.

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Monday, June 16, 2014 6:33 AM
  • Thanks Dave,

    the following code am using..

    Microsoft.Office.Interop.PowerPoint.Application ppApp= 

    new Microsoft.Office.Interop.PowerPoint.Application(); 
                ppApp.Visible = Office.MsoTriState.msoTrue; 
                Presentations ppPresens = ppApp.Presentations; 
                Presentation objPres = ppPresens.Open("C:\\Users\\lzgc4x\\Desktop\\test.pptx", Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue, Office.MsoTriState.msoTrue); 

                Slides objSlides = objPres.Slides; 
                Microsoft.Office.Interop.PowerPoint.SlideShowWindows objSSWs; 
                Microsoft.Office.Interop.PowerPoint.SlideShowSettings objSSS; 
                //Run the Slide show 
                objSSS = objPres.SlideShowSettings; 
                objSSWs = ppApp.SlideShowWindows; 
                for(int i = 1;i<=objSlides.Count;i++) 
                    objPres.SlideShowWindow.View.GotoSlide(i, Office.MsoTriState.msoFalse); 

                //while (objSSWs.Count >= 1) 
                //    System.Threading.Thread.Sleep(1000); 
                //Close the presentation without saving changes and quit PowerPoint 

    • Edited by asokfair Tuesday, June 17, 2014 1:31 PM
    Tuesday, June 17, 2014 1:30 PM
  • forget this. its office com. you not get this working in a store app. think you best stay with a desktop app if you want to do this.

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, June 17, 2014 1:33 PM
  • Yes, correct

    Initially i created C# application for Opening the Powerpoint it works fine with above code. and now i am integrating this power point code with windows store app (c#) but not working. any way to make it work?if not possible why ?

    also i noticed  "MessageBox.Show("")"  and Thread.Sleep()  these are not working with windows 8 app

    I want to open the powerpoint slideshow in my windows mobile using my own app.


    Ashok r

    Thursday, June 19, 2014 5:23 AM
  • See .NET for Windows Store apps for information about the parts of the .Net Framework that are available to Windows Store apps.

    As you note, MessageBox.Show and Thread.Sleep are not included there. Likewise, the Office API you are calling is not valid for Windows Store apps. The MessageDialog is similar in concept to MessageBox.Show. You can use Task.Delay for a significantly better version of the Sleep timer in your code snippet. Regardless of the platform, you should never hang your UI thread by calling an extended Sleep on it.

    The most straightforward way to show a PowerPoint or other Office document is to launch it into the default handler as Dave suggested, with the Launcher class. If you want to display the document in your own app you will need to find a 3rd party component to do so. I am not sure if anybody has published such a component for PowerPoint, but you can look for it in your favourite search engine.

    None of this will run in Windows Mobile. Windows Store apps run only on Windows, but Universal apps can share most source between Windows Store apps (running on Windows 8.1) and Windows Phone apps (running on Windows Phone 8.1).


    Thursday, June 19, 2014 5:41 AM
  • Ok, Thanks, i have one more question.

    can i convert this windows store app into normal C# app ? if possible how to i can archive that? i mean right now the project contains ".xml"  files. i want to make it work this app as normal C# app so that i can do whatever i want (only with windows 8 PC).


    Ashok r

    Friday, June 20, 2014 4:06 PM
  • You'll have to port it. How difficult this is depends on how the app was written. You'll probably need to redo the UI, but if you've separated your UI from your business logic (using MVVM or similar) then it probably won't be difficult to convert it to a WPF or Silverlight app.


    Friday, June 20, 2014 7:11 PM
  • Hi ,

    How do i can use "Process.Start " to RUN another exe file in Windows store App?


    Ashok r

    • Edited by asokfair Tuesday, June 24, 2014 5:56 PM
    Tuesday, June 24, 2014 5:56 PM
  • you can't

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, June 24, 2014 6:00 PM
  • Windows Store apps cannot directly launch other applications. As Dave suggested in his first response, Windows Store apps can launch files into the default handler for the file type with the Launcher class. This will allow the app to launch a pptx file and it will run in PowerPoint (assuming the user hasn't selected a different app to handle pptx files).


    Tuesday, June 24, 2014 6:21 PM
  • I am using the following code

               var options = new Windows.System.LauncherOptions();
                options.DisplayApplicationPicker = true;

                // Launch  file
                bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);

    Its working fine  and now i want to take controls , i mean i want to simulate keyboard key's like


    when i checked the namespace "System.Windows.Forms" __> "Forms" not found , Any alter method is there to simulate keyboard keys?


    Ashok r

    Tuesday, June 24, 2014 6:34 PM
  • No,WindowsStore apps cannot synthesize input. They cannot interact with or automate other apps
    Tuesday, June 24, 2014 6:56 PM