Page tree

Versions Compared

Key

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

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:

Csharpcode
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);

Option Strict On
Option Explicit On

Dim pptt As PowerPointTemplate = new
Vbnetcode
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 method:

Csharpcode
languagec#
 PowerPointApplication 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 PowerPointTemplatePowerPointApplication pptt = new PowerPointTemplatePowerPointApplication();
pptt.Open(templatePath);
pptt.BindData(valuesArray, colNamesArray,"DataSourceName", pptt.CreateDataBindingProperties());
pptt.Process(Dim present As Presentation = ppta.Open("StartingFile.pptx");

//--- CreateCode an instance of PowerPointApplication and
//--- open modifying and customizing the presentation youhere
created
withDim PowerPointTemplate.
//--- The presentation will be returned as a Presentation
//--- object.
PowerPointApplication ppta ppt As PowerPointTemplate = new PowerPointApplicationPowerPointTemplate();
Presentation pres = pptappt.Open(pptt);
Vbnet

Option Strict On
Option Explicit On

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);

ppta, present);