Saving a PowerPoint file using C #

I just need to create a .pptx file with 1 dummy slide using C # and save it in the current directory. Can someone tell me how to do this?

So far I have this code for creating a Powerpoint presentation:

 Microsoft.Office.Interop.PowerPoint.Application obj = new Application(); obj.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; 
+4
source share
3 answers

The following resources include how to save the file, as well as many other code examples on how to manipulate Ms - Power Point presentation files using C# :

http://code.msdn.microsoft.com/office/CSAutomatePowerPoint-b312d416

http://www.eggheadcafe.com/community/csharp/2/10068596/create-ppt-slides-through-cnet.aspx

Hope this helps

Edit:

The following is information about adding links:

http://support.microsoft.com/kb/303718

+1
source

This piece of code creates a new presentation:

  private void DpStartPowerPoint() { // Create the reference variables PowerPoint.Application ppApplication = null; PowerPoint.Presentations ppPresentations = null; PowerPoint.Presentation ppPresentation = null; // Instantiate the PowerPoint application ppApplication = new PowerPoint.Application(); // Create a presentation collection holder ppPresentations = ppApplication.Presentations; // Create an actual (blank) presentation ppPresentation = ppPresentations.Add(Office.MsoTriState.msoTrue); // Activate the PowerPoint application ppApplication.Activate(); } 

And this piece of code saves it:

  // Assign a filename under which to save the presentation string myFileName = "myPresentation"; // Save the presentation unconditionally ppPresentation.Save(); // Save the presentation as a PPTX ppPresentation.SaveAs(myFileName, PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Office.MsoTriState.msoTrue); // Save the presentation as a PDF ppPresentation.SaveAs(myFileName, PowerPoint.PpSaveAsFileType.ppSaveAsPDF, Office.MsoTriState.msoTrue); // Save a copy of the presentation ppPresentation.SaveCopyAs("Copy of " + myFileName, PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Office.MsoTriState.msoTrue); 

See this page for links to other Powerpoint automation features.

+1
source

Create such a file using PowerPoint and paste it as a resource into your C # application. Then copy it to a file when you need to.

0
source

Source: https://habr.com/ru/post/1416286/


All Articles