Getting a slide, Late binding, c#

Y

yevron2

Hello,

I am trying to use the PowerPoint object model with late binding. I
want to go over all the slides. The attached code works accept the part
that gets the slide from the slides collection of the presentation.
With early binding it works... Does anyone know why that is???

Thank you.

The code:
========

string fileName = "c:\\mdlc.ppt";

// get the implementing COM object
Type comType = Type.GetTypeFromProgID("PowerPoint.Application");

// Create an INstance of the Power point Application Object
object application = Activator.CreateInstance(comType);

// Get the presentations Property
object presentations = comType.InvokeMember ("Presentations",
System.Reflection.BindingFlags.GetProperty ,null, application, null );


// Opening the presentation
object presentation = presentations.GetType().InvokeMember("Open",
System.Reflection.BindingFlags.InvokeMethod, null, presentations,new
object[] { fileName, Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse });

// Getting all the slides
object slides = presentation.GetType().InvokeMember ("Slides",
System.Reflection.BindingFlags.GetProperty , null, presentation, null
);

// Getting the slides count
int slidesCount = (int)slides.GetType().InvokeMember ("Count",
System.Reflection.BindingFlags.GetProperty , null, slides, null );

// Going over all the slides
for(int i = 1; i <= slidesCount; i++)
{

//=============================================
// Why doesn't it work???
//=============================================
// Getting the current slide
object slide = slides.GetType().InvokeMember("_Index",
System.Reflection.BindingFlags.InvokeMethod, null, slides , new
object[] { i });

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top