RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


The Baker's Dozen: 13 Productivity Tips for Generating PowerPoint Presentations : Page 3

In this installment of "The Baker's Dozen" you'll get some handy tips on creating Office eye candy: generating PowerPoint output.

Tip 5: Baker's Dozen Spotlight: Building an Excel Spreadsheet to Generate a PowerPoint Table or a Chart Object
Often, creating/generating a PowerPoint slide also involves creating an Excel table. It may be a temporary table, where the contents are pasted into a PowerPoint table or used to create an Excel Chart Object (also pasted into PowerPoint). The next few tips will cover examples of this. The contents may be all numeric entries or a combination of entries, and they may or may not include column headings and alignment definitions.

Building a set of reusable classes for PowerPoint output is similar to constructing any other component. You design the class, prototype, test, and refactor.
GenPPT includes a method called BuildExcelTable to generate a temporary Excel table (see Listing 1). This method receives two parameters: a DataTable representing the rows/columns (DtTableEntries), and an optional DataTable containing column headings and alignment definitions (DtHeadings). BuildExcelTable performs the following:

  • Adds a new workbook to the oExcel application object
  • Writes out column heading lines and sets the alignment for each column (using DtHeadings)
  • Writes out the actual data (by scanning through DtTableEntries)
  • Selects the entire range of cells written out, and copies them to the system clipboard (for subsequent pasting into PowerPoint)
  • Returns a string representing the range of cells ("A1: D10")
Note that Listing 1 also references a method called WriteExcelCell. As the name implies, the method writes out a value for a particular cell. Calling methods use it when iterating through row/column objects. The next tip will present some code to utilize this capability.

Figure 3: Generating a table.
Tip 6: Creating a Slide that Displays an Excel Table
Now that you have a class to build a table, you can provide some data to populate it. Listing 2 and Listing 3 show examples of calling GenPPT with data to build a table that will result in the third slide (see Figure 3).

Tip 7: Building an Excel Table that Can Be Used as a Source of a Excel Chart Object
Now that I've covered bullet points and tables, let's have some fun and throw charts into the mix. Using the same manner that provided data to GenPPT to generate a table, you can do the same thing to generate charts.

Figure 4: Generating a table and a chart.
Suppose you define a DataTable and pass it to GenPPT; GenPPT can use the method to build a temporary Excel table and then use the range of cells to generate an Excel chart object. Once GenPPT generates the chart object, it can programmatically copy the chart image to the Windows clipboard and then paste it into a slide that utilizes a chart.

This time I'll work backwards ("begin with the end in mind"). Figure 4 contains the slide you'll want to create: a table on the left and an exploded pie chart on the right.

Listing 4 shows how to call GenPPT to generate this output. The following two tips cover the actual GenPPT methods to create the chart.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date