Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Powerpoint/Keynote Presentations with scriptability?

Lately I have been creating PowerPoint presentations to companies. I have mostly been doing this in PowerPoint. Basically they are created by the same design, but just different numbers in set places, and different numbers used to generate the PowerPoint bar graph / pie graph stuff. (basically there are these pie graph objects when inserted, give you an option to change the design, and input the numbers in some excel spreadsheet that pops up).

Let's say I'm doing this for 100 companies: isn't there a way to just specify all the different values I need, and have the powerpoint created somehow? I can provide a design base, all it needs to do is just go in and change dynamic values (nothing raster).

This isn't even a question necessarily for PowerPoint: if I could do this with Keynote (as in, automate pie graphs, bar graphs, and set places with numbers & static text), then that works too.

Edit: I mentioned that I know that PowerPoint pie graphs / bar graphs are generated from Xxcel spreadsheets. There are about 3 of these in my presentation, along with other changing values in static positions, across 100 or so presentations. I am looking to script all or the majority of the process.

Edit: Using PowerPoint 2007, or the newest version of Keynote. Preferred method of scripting with Keynote would probably be AppleScript, with PowerPoint 2007, either Python/Django or macros.

like image 660
Rey Avatar asked Nov 06 '22 18:11

Rey


1 Answers

Sorry this has taken a few days to get back to you, had to work out an issue. Here's a quick and efficient way to do what you're asking for.

  1. Create a macro-enabled PowerPoint.
  2. Create a single pie chart on the first slide via the Insert|Chart command in the Ribbon. Excel will open. In the columns, on the Horizontal (Category) Axis leave as is (i.e. 1st Qtr, 2nd Qrt, etc.). On the Legend Entries (Series) Axis, expand a few columns and add more data. Ensure column names are unique.
  3. Close Excel
  4. Press Alt+F11 to go to the VBE.
  5. Copy/Paste the code below into a new module, changing the following variables: chartTemplatePath and, if needed, sc.Name, to something else of your choosing.
  6. Click F5 in the subroutine to run. You should now have as many charts slides as there are columns.

.

Sub CreateChartDecksandSave()
    Dim chartTemplatePath As String
    chartTemplatePath = "C:\Temp\"

    Dim myPPT As Presentation
    Set myPPT = ActivePresentation

    Dim mainChart As Chart
    Set mainChart = myPPT.Slides(1).Shapes(1).Chart

    Dim scCount As Integer
    scCount = mainChart.SeriesCollection.Count

    Dim sc As Series

    For i = 1 To scCount
        Set sc = mainChart.SeriesCollection(1)
        myPPT.SaveCopyAs (chartTemplatePath & sc.Name & ".pptx")
        sc.Delete
    Next
End Sub

If you're working with this and the chart data disappears from the main PPT, that's okay, just select the chart, go to Chart Tools | Design | Select Data and reselect your data set as the whole table.

like image 121
Todd Main Avatar answered Nov 15 '22 06:11

Todd Main