Wednesday, June 28, 2017

C# codes for working with powerpoint

cs-vsto-powerpoint-writer


Package provides VSTO-based C# implementation of a powerpoint modifier

Objective

The project is to create a simple library which uses VSTO to automate powerpoint modification by using C# DSL syntax.

Langauage

C#

Install

The library was built using VS2015 Community Edition. You can clone and build the library then add the library to your references in a .NET project. Note that this library is based on VSTO and thus requires the availability of office 2007 for it to work. It also requires the following COM libraries to be available in the C# project's references
  • Microsoft.Office.Core (Version: 2.4)
  • Microsoft.Office.Interop.Excel (Version: 1.6)
  • Microsoft.Office.Interop.Powerpoint (Version: 2.9)
This link below shows how to solve the COM error when uninstall vs 2007 and reinstall some other version of office and then reinstall vs 2007:

Usage

Below is the C# sample code for modifying the input.ppt and producing the output.ppt:
PowerPointReportModifier builder = new PowerPointReportModifier();
builder.ChartIntercepted += (sender, e) =>
{
 string title = e.Title;
 PowerPoint.Chart chart = e.Chart;
 Worksheet sheet = e.Worksheet;

 // code to modify the chart here
};
builder.TableIntercepted += (sender, e) =>
{
 PowerPoint.Table table = e.Table;

 // code to modify the table here
};
builder.TextFrameIntercepted += (sender, e) =>
{
 PowerPoint.TextRange paragraph = e.Paragraph;
 
 // code to modify the paragraph here
};

builder.Apply("input.ppt", "output.ppt");

No comments:

Post a Comment