Friday, September 21, 2012

IntropServices Automation with PowerPoint

IntropServices Automation with PowerPoint

Hello,

I am attempting to create a powerpoint from my silverlight application.  I have succedded in creating the powerpoint and adding a slide, but I cannot seem to add a textbox, or change the title.  I have been using the PowerPoint Object Model Reference (http://msdn.microsoft.com/en-us/library/office/bb265987(v=office.12).aspx) to try and figure out how to add objects, but it is written in VBA and I need C#.  Could anyone direct me to the correct translation in order to add textboxes and titles from UIelements in my XAML.  Thanks in advance!

 

Code:

using System.Runtime.InteropServices.Automation;

using Microsoft.CSharp;

private void pptExport(Object sender, RoutedEventArgs e)

{

//This first part works great.  The ppt opens and adds slide successfully

dynamic PowerPointApp = AutomationFactory.CreateObject("PowerPoint.Application");

PowerPointApp.Visible = true;

dynamic Presentation = PowerPointApp.Presentations.Add();

Presentation.Slides.Add(1, 1):

dynamic document = Presentation.Slides(1);

//This part I cannot seem to get to work correctly and have probably translated the VBA incorrectly

dynamic text1 = Presentation.Slides(1).Shapes.AddShape();

text1.TextFrame.Text = TextBlock1.Text;

}

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog