Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

PowerPointWriter allows you to generate a presentation from script alone, using the PowerPointApplication object, or from a template presentation and a script using PowerPointTemplate. PowerPointTemplate provides an intuitive high-performance way to import database values to a presentation, but cannot otherwise modify a presentation at runtime. The PowerPointApplication object model allows you to modify additional aspects of the presentation at runtime.

Excerpt

You can take advantage of the features of both PowerPointApplication and PowerPointTemplate by using them together. For example, you can use PowerPointTemplate to open and populate a PowerPointWriter template, then pass the populated presentation to PowerPointApplication

...

to modify document properties.

PowerPointTemplate to PowerPointApplication

To pass a presentation from PowerPointTemplate to PowerPointApplication, do not call PowerPointTemplate.Save. Instead, pass the PowerPointTemplate object to PowerPointApplication's Open method:

Code Block
c#
languagec#
 PowerPointTemplate PowerPointTemplate pptt = new PowerPointTemplate();
pptt.Open(templatePath);
pptt.BindData(valuesArray, colNamesArray,"DataSourceName", pptt.CreateDataBindingProperties());
pptt.Process();

//--- Create an instance of PowerPointApplication and
//--- open the presentation you created with PowerPointTemplate.
//--- The presentation will be returned as a Presentation
//--- object.
PowerPointApplication ppta = new PowerPointApplication();
Presentation pres = ppta.Open(pptt);
Code Block
languagevb
 Dim pptt As PowerPointTemplate = new PowerPointTemplate();
pptt.Open(templatePath);
pptt.BindData(valuesArray, colNamesArray,"DataSourceName", pptt.CreateDataBindingProperties());
pptt.Process();

//--- Create an instance of PowerPointApplication and
//--- open the presentation you created with PowerPointTemplate.
//--- The presentation will be returned as a Presentation
//--- object.
Dim ppta As PowerPointApplication = new PowerPointApplication();
Dim pres As Presentation = ppta.Open(pptt);

PowerPointApplication to PowerPointTemplate

To pass a presentation from PowerPointApplication to PowerPointTemplate, do not call PowerPointApplication.Save. Instead, pass the PowerPointApplication object, along with the Presentation object that you want to populate, to PowerPointTemplates's Open method:

Code Block
languagec#
 PowerPointApplication ppta = new PowerPointApplication();
Presentation present = ppta.Open("StartingFile.pptx");

//--- Code modifying and customizing the presentation here

PowerPointTemplate ppt = new PowerPointTemplate();
ppt.Open(ppta, present);
Code Block
languagevb
 Dim ppta As PowerPointApplication = new PowerPointApplication();
Dim present As Presentation = ppta.Open("StartingFile.pptx");

//--- Code modifying and customizing the presentation here

Dim ppt As PowerPointTemplate = new PowerPointTemplate();
ppt.Open(ppta, present);