none
PowerPoint SaveAs method does not work for empty presentations RRS feed

  • Question

  • Hi

    When I use the SaveAs method of  Microsoft.Office.Interop.PowerPoint.Presentation I have found that an exception is thrown for presentations that do not have any slides (empty presentation file).

    Is there a workaround for this?

    Thank you,

    Charu


    charu

    Thursday, May 29, 2014 4:01 PM

Answers

  • Hi Charu,

    What is your PowerPoint version?

    According to my investigation, we can save a no slide presentation file Through PowerPoint PowerPoint 2013 API.

    static void AddSlide2013()
            {
                PPT.Application pptapp = new PPT.Application();
                pptapp.Visible = MsoTriState.msoCTrue;
                PPT.Presentation pre = pptapp.Presentations.Add();
                pre.SaveAs("D:/TestnoslidePPT.pptx");
                pptapp.Quit();
                pptapp = null;
            }
    

    For PowerPoint 2007 or 2010, we also can save a no slide presentation file:

    static void AddSlide2007or2010()
            {
                PPT.Application pptapp = new PPT.Application();
                pptapp.Visible = MsoTriState.msoCTrue;
                PPT.Presentation pre = pptapp.Presentations.Add(MsoTriState.msoCTrue);
                pre.SaveAs(@"D:/TestnoslidePPT", PPT.PpSaveAsFileType.ppSaveAsPresentation, MsoTriState.msoCTrue);
                pptapp.Quit();
                pptapp = null;
            }

    Can you save a no slide presentation manually?

    If no, for a workaround, you could add a blank slide before saving:

    Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout = pre.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
    Microsoft.Office.Interop.PowerPoint.Slide s = pre.Slides.AddSlide(1, customLayout);
    If I misundertood, please let me know.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 30, 2014 7:23 AM
    Moderator

All replies

  • Why do you need to save a presentation without slides?
    Thursday, May 29, 2014 4:17 PM
  • Hi Charu,

    What is your PowerPoint version?

    According to my investigation, we can save a no slide presentation file Through PowerPoint PowerPoint 2013 API.

    static void AddSlide2013()
            {
                PPT.Application pptapp = new PPT.Application();
                pptapp.Visible = MsoTriState.msoCTrue;
                PPT.Presentation pre = pptapp.Presentations.Add();
                pre.SaveAs("D:/TestnoslidePPT.pptx");
                pptapp.Quit();
                pptapp = null;
            }
    

    For PowerPoint 2007 or 2010, we also can save a no slide presentation file:

    static void AddSlide2007or2010()
            {
                PPT.Application pptapp = new PPT.Application();
                pptapp.Visible = MsoTriState.msoCTrue;
                PPT.Presentation pre = pptapp.Presentations.Add(MsoTriState.msoCTrue);
                pre.SaveAs(@"D:/TestnoslidePPT", PPT.PpSaveAsFileType.ppSaveAsPresentation, MsoTriState.msoCTrue);
                pptapp.Quit();
                pptapp = null;
            }

    Can you save a no slide presentation manually?

    If no, for a workaround, you could add a blank slide before saving:

    Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout = pre.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
    Microsoft.Office.Interop.PowerPoint.Slide s = pre.Slides.AddSlide(1, customLayout);
    If I misundertood, please let me know.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 30, 2014 7:23 AM
    Moderator