Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Architecture
ASP.NET
ASP.NET MVC
ASP.NET WebForms
B2B (Business Integration)
BizTalk
Book Excerpts
Build and Deploy
C#
C++
Code Contracts
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Design Patterns
Development Process
Display Technologies
Distributed Computing
DotNetNuke
DSL
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Graphics
Internet Explorer 8.0
Interviews
iPhone
Java
Java Script
jQuery
LINQ
Linux
Mac OS X
MDX
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
Network
NHibernate
Object Oriented Development
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
Podcasts
Post Mortem
PowerPoint
Print/Output
Product News
Product Reviews
Project Management
Python
Q&A
Reporting Services
REST
RIA Services
Ruby
Search
Security
Services
SharePoint
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server CE/AnyWhere/Mobile/Compact
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
Tips
UI Design
UML
User Groups
VB Script
VB.NET
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WF
Whitepapers
Windows 7
Windows Azure
Windows Live
Windows Server
Windows Vista
WinForms
Workflow
WPF
XAML
XML
XNA
XSLT



INSTANTLY dtSearch® TERABYTES OF TEXT


 


State of .NET


Reader rating:
Click here to read 5 comments about this article.
Article source: CoDe (2006 - Nov/Dec)


Article Pages:  1  2 3 4 5 - Next >


The Baker’s Dozen: 13 Productivity Tips for Generating PowerPoint Presentations

This installment of “The Baker’s Dozen” finds the Baker expanding from pastries to eye candy: generating PowerPoint output. Many power users build presentations using data from Excel or other data sources. This article shows how to automate Microsoft PowerPoint 2003 from within a Visual Studio 2005 application. The article presents a class called GenPPT, which creates several different types of slides, including slides that integrate tables and charts. GenPPT is written in Visual Basic 2005, and the demo program that calls it is written in C#: this demonstrates using multiple .NET languages in a solution.

Beginning with the End in Mind

Several times in the last year, I’ve seen online questions about generating PowerPoint output automatically. Just like Microsoft Word and Microsoft Excel, PowerPoint contains a rich object model that a developer can utilize to generate attractive and appealing slideshows. So I decided to devote a Baker’s Dozen article to the topic of PowerPoint automation within Visual Studio 2005.

"
If you’re not sure how to perform a specific programming task in PowerPoint (or any Microsoft Office Product), create a macro and then perform the task. In most instances, the code in the VBA macro will show you the way.
"

This article presents a Visual Basic 2005 class that aids a developer with the following PowerPoint tasks:

  • General structure of PPTGen
  • Creating an instance of PowerPoint
  • Starting a new presentation with a template and a title page
  • Creating a text-only slide with a title and a set of bullet points
  • Baker’s Dozen Spotlight: building an Excel table that you can use to generate a PowerPoint table or a Chart object
  • Creating a slide that displays an Excel table
  • Building an Excel table that you can use as a source for an Excel chart object
  • Customizing the display of an Excel chart object
  • Creating a slide that displays both a table and a pie chart
  • Creating a slide that displays a line chart
  • Setting animations and slide transitions
  • Defining page footer information
  • Saving and displaying the presentation

Deciding on an example to illustrate a set of classes can be an interesting thought process. Initially I was going to use data from the Northwind database-but since it’s near the end of the football season (I’m writing this in mid-December), I decided to have some fun with it. I am a big Kansas City Chiefs fan, and it was only a few years ago that KC started the season 9-0 and had Super Bowl hopes. Of course, it didn’t turn out that way, but I decided to build a PowerPoint presentation on their 2003 season. Here we go!

Tip 1: General Information for GenPPT

GenPPT is a DLL, written in Visual Basic 2005. It contains COM references to the Microsoft Excel 11.0 and Microsoft PowerPoint 11.0 Object Libraries. It also contains COM references to Microsoft Core Office Library and Visual Basic for Application Extensibility: Visual Studio 2005 automatically adds these references when you add the PowerPoint and Excel object libraries.

To add these libraries manually, bring up the Solution Explorer window (from the View menu choose Solution Explorer), navigate to the References folder, right-click and choose “Add Reference.” From the Add Reference window, click the COM tab and scroll down to the Microsoft Excel and Microsoft PowerPoint Object Libraries to select them.

GenPPT contains one class file, PowerPointTools.VB. The class contains the following import statements to access the PowerPoint and Excel object models.

Imports PowerPoint = 
Microsoft.Office.Interop.PowerPoint

Imports Graph = Microsoft.Office.Interop.Graph
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Drawing

Table 1 and Table 2 list all the public properties and methods of GenPPT. GenPPT also contains a few support methods for common tasks (Table 3).

Tip 2: Creating an Instance of PowerPoint

Kicking off GenPPT is easy-add a reference to PowerPointTools.DLL to your project and then run the following code.

// Create instance of GenPPT
PowerPointTools oPPT = new PowerPointTools();
oPPT.LaunchPPT();

The code for LaunchPPT creates new instances for PowerPoint 2003 and Excel. Note that the method utilizes the object property references to oPPTApp and oExcel, which other methods in the class will use.

Public Sub LaunchPPT()
Me.oPPTApp = New PowerPoint.Application
Me.oPPTApp.Visible = False

Me.oExcel = New Excel.Application
Me.oExcel.Visible = False

Me.SlideNumber = 0
End Sub
&

By: Kevin S Goff

Kevin S. Goff, a Microsoft MVP award recipient for 2007, is the founder and principal consultant of Common Ground Solutions, a consulting group that provides custom Web and desktop software solutions in .NET, VFP, SQL Server, and Crystal Reports. Kevin is the author of Pro VS 2005 Reporting using SQL Server and Crystal Reports, published by Apress. Kevin has been building software applications since 1988. He has received several awards from the U.S. Department of Agriculture for systems automation. He has also received special citations from Fortune 500 Companies for solutions that yielded six-figure returns on investment. He has worked in such industries as insurance, accounting, public health, real estate, publishing, advertising, manufacturing, finance, consumer packaged goods, and trade promotion. In addition, Kevin provides many forms of custom training. Contact Kevin at kgoff@commongroundsolutions.net

kgoff@commongroundsolutions.net

Fast Facts

The GenPPT class contains a set of starter productivity methods for building PowerPoint slides from a .NET application. GenPPT assists a developer in building slides with multiple levels of bullet points, tables, and charts.



Table 1: GenPPT public properties
PropertyDescription
oPPTAppObject reference to the PowerPoint application
oExcelObject reference to the Excel application
SlideNumberCurrent slide number
oSheetObject reference to the current Excel worksheet


Table 2: Primary GenPPT public methods
Method Description
LaunchPPTCreates an instance of Powerpoint and Excel
SetTemplateDefines the default template to be used
SetFooterDefines the footer of the PPT
BuildTitlePageBuilds the PPT title page slide
BuildBulletPageBuilds a slide of bullet points, using a DataTable source
BuildTablePageBuilds a slide with a table, using a DataTable source
BuidTableChartPageBuilds a slide with a table and chart, using DataTable sources
BuildChartPageBuilds a slide with a chart, using a DataTable source
SavePPTSaves the generated PPT
DisplayPPTDisplays the generated PPT
AddPictureAdd a picture to be centered on the current slide
BuildFooterBuild a footer
SetSlideTransitionsSets the slide-to-slide transition effect


Article Pages:  1  2 3 4 5 - Next Page: 'Tip 3: Starting a New Presentation with a Template and a Title Page' >>

Page 1: The Baker’s Dozen: 13 Productivity Tips for Generating PowerPoint Presentations
Page 2: Tip 3: Starting a New Presentation with a Template and a Title Page
Page 3: Tip 5: Baker’s Dozen Spotlight: Building an Excel Spreadsheet to Generate a PowerPoint Table or a Chart Object
Page 4: Tip 8: Customizing the Display of an Excel Chart Object
Page 5: Tip 12: Defining Slide Footer Information

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
4.0 out of 5

26 people have rated this article.

      ESDC

 

CODE TRAINING