Harvesting data from PowerPoint

Hi,

I’m interested in harvesting data from powerpoint for use in another application via xml. I’ve downloaded the demo and can’t find an example that uses templates in this fashion.

The template example you have provided instead relies on the text value in the power point text box to determine what to publish. As in…

if (th.Text == “H1”)

th.Paragraphs[0].Portions[0].Text = “Demo Presentation”;

This is OK if you want to publish to PP from another source, but this will not work going in the other direction. For example, what if I wanted collect the text in the text area containing “H1” no matter what text it contained?

It seems to me that my solution will require that my PowerPoint template have some way to “tag” text fields with some kind of meta data indicator. I suppose I could use something like substring() to check that “H1” precedes the text contained in a text area. This is somewhat less than ideal as it requires that my powerpoint users not break this. Is this making any sense? Do you have any suggestions for me? Thanks!

Peter

After further investigation I am wondering if I could use the MainMaster class to achieve this? For example, does the Asposeppt API provide access to a MainMaster placeholder?

Dear Peter,

Please check Programmer’s Guide, especially chapter about shapes. It shows how to use alternative text to find shapes on a slide.

About MainMaster placeholders.
At first, what would you like to find? TextHolders or TextFrames?
MainMaster doesn’t contain real text holders. It’s just a template without any text.

Thanks! I think this is precisely what I was looking for. I haven’t used Powerpoint too much myself and so I wasn’t sure where to look.

So it sounds like I should label all the shapes in my Powerpoint template that have data I want to capture and then use something like.

Shape FindShape(Slide slide, string alttext)
{
for (int i = 0; i < slide.Shapes.Count; i++)
if (slide.ShapesIdea.AlternativeText.CompareTo(alttext) == 0)
return slide.ShapesIdea;
return null;
}

Shape shape = FindShape(slide, “Shape1”)

myXMLnode.text = shape.AlternativeText;

I haven’t tried this of course and this code doesn’t contain an XML document instantiation, but I’m thinking this will work.

This seems to me like something that might be useful to other people? I think it might be a good sample to be added to the documentation.

Thanks again.

Peter

Dear Peter,

I think you would like to capture real text (not label) so you have to write:

TextFrame frame = FineShape(slide, “Shape1”) as TextFrame;
if (frame != null)
myXMLnode.text = frame.Text;

Thanks so much!