VSTO add-in to automatically export custom PowerPoint slide shows

One of my company’s groups works on a very large PowerPoint slide slide. Not all slides in this deck are relevant to everyone. The goal of this deck is to have a unique source of material that people can choose and choose slides, depending on the type of presentation that is needed. There are several predefined custom slide shows in the slide deck to facilitate this process.

Although this solution works well in many cases, we need an easy way to quickly export a custom flash presentation to a new presentation. I am going to develop a VSTO add-in that will allow the user to select one or more custom slide shows and then export the slide shows to their desktop, and I'm looking for some code that will help me along the way.

Does anyone know how to export an existing custom show to a new presentation? Even better, is there a way to allow users to select and export one or more existing impressions?

+4
source share
2 answers

Great question, I wanted to do it myself for a long time, so I took the time to figure it out for you (and me!).

Basically, you need to: a) skip all NamedSlideShows , b) find the slides on the SlideID , c) add a new presentation, and then d) copy the NamedSlideShow slides with the original design, you can do this for one or all of your custom shows, based on how you send commands.

Here is an example:

 Sub FindShows() Dim p As PowerPoint.Presentation Set p = PowerPoint.ActivePresenation Dim cShow As PowerPoint.NamedSlideShow For Each cShow In p.SlideShowSettings.NamedSlideShows SaveCustomShow (cShow.Name, p) 'If using PowerPoint 2010 use the following line instead: 'SaveCustomShow cShow.Name, p Next End Sub 

The FindShows simply finds all the custom displays in ActivePresentation and sends them to a routine that will create each new presenation based on the specified custom display name. You can customize it as needed.

This routine below is the heart. A few things to note:

  • To send a slide design to the source of the slide, you must explain to set the copied slide to use this design.
  • A NamedSlideShow will only give you SlideID slides inside it. You can use FindBySlideID to then determine what the slide in the original view is - it returns a slide object. Then you just copy it and paste it using the original.
  Sub SaveCustomShow(showName As String, p As Presentation) Dim cShows As PowerPoint.NamedSlideShows Set cShows = p.SlideShowSettings.NamedSlideShows Dim cSlideIDs As Variant cSlideIDs = cShows(showName).SlideIDs Dim destinationPath As String destinationPath = "C:\Temp\" Dim newP As PowerPoint.Presentation Set newP = PowerPoint.Presentations.Add(WithWindow:=False) With newP .SaveAs destinationPath & cShows(showName).Name Dim s As PowerPoint.Slide Dim e As Integer For e = 1 To UBound(cSlideIDs) Set s = p.Slides.FindBySlideID(SlideID:=cSlideIDs(e)) s.Copy .Slides.Paste.Design = s.Design Next .Save .Close End With Set newP = Nothing End Sub 

There is no error checking in the code, so it will need to be developed, but it works like a charm!

+5
source

It works! first create a copy of the file!

http://www.pptfaq.com/FAQ00893.htm

+1
source

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


All Articles