none
Power Point 2010 automation help RRS feed

  • Question

  • Hi,

     

    Not sure if this is possible but i need to be able to play power point presentations within in specific screen area (i.e. Screen Location 0,0 - Width 1000px - Height 200px) via C# (office automation)

     

    Can anybody suggest how this may be achived?

     

    Thanks,

    Dora9

     

     


    Student [Visual C#.Net / VB.Net]
    Monday, February 6, 2012 10:38 PM

Answers

  • Hi Dora9,

    Thanks for your post.

    You can specify the ShowType of the show setting to ppShowTypeWindow, see the code:

    Sub ShowPresentation()
        'specify a presentation
        Dim pre As Presentation
        Set pre = Application.Presentations(1)
        
        'change window state to normal to enable
        'changing left, top, with and height properties of window
        Application.WindowState = ppWindowNormal
        With pre.SlideShowSettings
            'change to show within a window
            .ShowType = ppShowTypeWindow
            
            'specify the location and size of the slide show window
            With .Run
                .Left = 0
                .Top = 0
                .Width = 500
                .Height = 500
            End With
        End With
    End Sub

    I hope this helps.


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, February 7, 2012 6:15 AM
    Moderator
  • Hi,

    You can monitor the count of the SlideShowWindows continually, as soon as there is no SlideShowWindow, execute the next line, see the code :

     
                PowerPoint.SlideShowWindow showWindow= objSSS.Run(); 
                //Wait for the slide show to end.
                PowerPoint.SlideShowWindows objSSWs = objApp.SlideShowWindows;
                while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);
    
                //your next code

    I hope this helps.

    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, February 8, 2012 9:23 AM
    Moderator

All replies

  • Hi Dora9,

    Thanks for your post.

    You can specify the ShowType of the show setting to ppShowTypeWindow, see the code:

    Sub ShowPresentation()
        'specify a presentation
        Dim pre As Presentation
        Set pre = Application.Presentations(1)
        
        'change window state to normal to enable
        'changing left, top, with and height properties of window
        Application.WindowState = ppWindowNormal
        With pre.SlideShowSettings
            'change to show within a window
            .ShowType = ppShowTypeWindow
            
            'specify the location and size of the slide show window
            With .Run
                .Left = 0
                .Top = 0
                .Width = 500
                .Height = 500
            End With
        End With
    End Sub

    I hope this helps.


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, February 7, 2012 6:15 AM
    Moderator
  • Hi, 

    The following code is written in C# and seems to work although i need to remove the Windows Form styling from Windowed Mode, any ideas how i can do this?

    static void LoadPPT() { var strTemplate = @"C:\1.pptx"; PowerPoint.Application objApp; PowerPoint.Presentations objPresSet; PowerPoint._Presentation objPres; PowerPoint.SlideShowWindows objSSWs; PowerPoint.SlideShowSettings objSSS; // Open a new presentation objApp = new PowerPoint.Application(); objApp.Visible = MsoTriState.msoCTrue; objPresSet = objApp.Presentations; objPres = objPresSet.Open(strTemplate, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse); // Set as window with a specific Width and height objPres.Application.Width = 400; objPres.Application.Height = 400; objPres.Application.Left = 0; objPres.Application.Top = 0; objPres.Application.WindowState = PowerPoint.PpWindowState.ppWindowNormal; objPres.SlideShowSettings.ShowMediaControls = MsoTriState.msoFalse; objPres.SlideShowSettings.ShowScrollbar = MsoTriState.msoFalse; objSSS = objPres.SlideShowSettings; objSSS.StartingSlide = 1; objSSS.EndingSlide = 3; objSSS.Run(); //Wait for the slide show to end. Console.WriteLine("Press any key to exit");

    Console.ReadLine();

    //Close the presentation without saving changes and quit PowerPoint. objPres.Close(); objApp.Quit(); }


    Also i do i know when the show has finished playing? Currently i am using the following (which i no good, need to do automatically); -

    Console.WriteLine("Press any key to exit!");
                Console.ReadLine()

    Thanks,

    Dora9


    Student [Visual C#.Net / VB.Net]

    Tuesday, February 7, 2012 3:46 PM
  • Hi,

    You can monitor the count of the SlideShowWindows continually, as soon as there is no SlideShowWindow, execute the next line, see the code :

     
                PowerPoint.SlideShowWindow showWindow= objSSS.Run(); 
                //Wait for the slide show to end.
                PowerPoint.SlideShowWindows objSSWs = objApp.SlideShowWindows;
                while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);
    
                //your next code

    I hope this helps.

    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, February 8, 2012 9:23 AM
    Moderator
  • Hi,

    Thanks for your help, any ideas how i can remove the form borders around the windowed powerpoint show? 

    Thanks 

    Dora9


    Student [Visual C#.Net / VB.Net]

    Thursday, February 9, 2012 4:12 PM
  • Hi,

    Thanks for your help, any ideas how i can remove the form borders around the windowed powerpoint show? 

    Thanks 

    Dora9


    Student [Visual C#.Net / VB.Net]

    Hi,

    As far as I know, you can't do this. There is no such approach provided by Office PIAs to remove the form borders. 

    I hope this helps.


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Friday, February 10, 2012 5:52 AM
    Moderator
  • Any update?


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, February 15, 2012 8:36 AM
    Moderator