0
votes

I am trying to extract text from specific text boxes in a PowerPoint template to fill a web form using OpenXml and C#.

So far, what I have seen online iterates through all text boxes using Slide.Descendants<TextBody>() in a foreach loop, or selects only the first or last text box using Slide.Descendants<TextBody>().First().

If I know that the text I am looking for is contained in say textBody10, is there a way for me to access that text body directly, or is there a way to identify the name of a given textbody within the foreach loop?

1
Have you had a look at the Open XML markup of some sample slides? If you do that, it might become obvious what kind of Linq query you will need to select an element, e.g., based on the value of an attribute of that or a related element.Thomas Barnekow

1 Answers

0
votes

To solve the problem, I used a trial-and-error approach. I indexed the foreach loop with a local variable to identify the TextBody relevant to each field in the form. I am not sure about the robustness of this solution, but it seems to be working fine for now. If anyone has a more elegant solution, I would gladly hear it.