We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Editing MainMaster slide


I have been given some PPTs that include text in the Master Slide which I am trying to change. I can find the text by walking the Shapes property of the Slide. When I find the TextFrame that I am looking for, I change the Text property and write out the PPT.

If I change the TextFrames in the MasterTextHolder, the resulting PPT gives the following error when opened w/ PPT viewer:
PowerPoint Viewer cannot open the file “output.ppt” because the file is corrupted.

If I change ONLY the TextFrame that I really want in some shape that is NOT the MasterTextHolder, the resulting PPT loads in PPT viewer, but the text isn’t changed.

Basically, this PPT uses the Master Slide to create a “footer” that is shown on every slide and I’m trying to find a way to change the text in the footer.

I found the following thread that seemed relevant:

<a href="https://forum.aspose.com/t/99010

Is there any more known info on this issue?

- J


Hi,

You can add the alternative text to the footer and hence change the footer text this way:

MainMaster mm = pres.MainMaster;

foreach(Aspose.Slides.Shape shp in mm.Shapes)

if (shp.IsMasterTextHolder)

{

TextFrame tf = shp.TextFrame;

if (shp.AlternativeText == "txt")

tf.Text = "New Footer";

}


Sorry, I’m not really following you. Why are you only modifying Shapes that are “MasterTextHolders”?

The PPTs that I have received were created by someone else and I was hoping to use them “as-is” without having to make any edits (other than replacing a few words in the text). The text that appears at the bottom of all the slides I have determined to be part of the MainMaster, however, it is a Shape which is NOT a MasterTextHolder. If I walk the Shapes, find the text, and attempt to modify it by using:
tf.Text = "My new footer"
It does not work. When I open the saved PPT, the original text is there, not the “My new footer” text that should be there. I use the same technique for modifying text on other Slides and it works great. So there seems to be something different about the MainMaster.

Does that make sense?

jbruce:

If I walk the Shapes, find the text, and attempt to modify it by using:
tf.Text = "My new footer"
It does not work.

Are you sure, you really found the text to be replaced. I didn't find any problem changing text in the non-MasterTextHolder shapes.

In your previous post, you asked to change the footer text and i provided you the sample for that, which is valid for a standard footer on master slide.

Anyway, can you please provide the source presentation to investigate?

Your question about “really finding the text” made me re-check and I believe I have determined the problem.

The PPT (which was not authored by me) actually had multiple Slide Master slides. I’m not a big PowerPoint user, so I didn’t realize this was possible. It turns out that the author created 2 identical Slide Masters and was using the second one they created. I was finding and changing the first one, which of course resulted in no visual changes when the PPT was saved (since the found Slide Master was not actually part of any of the actual slides).

When I changed my code to iterate through all Slide Masters, it worked as expected.

I would like to make one suggestion. There should be more discussion of and an increased emphasis on the “Masters” collection/property in the documentation. In most (if not all) of the sample code I have seen (either installed with Aspose.Slides or discussed here on the forums) that iterates through the slides (extracting text, cloning slides, etc.), the Slide Master slides are never accounted for. Here are just 2 threads that don’t take it into account (there are many other examples) :

Extract text from powerpoint presentation
Updating from vers. 3.0.1.15296 to 3.1.0.0 broke my code

It would have been better if there was some code accounting for the Slide Masters text.

Hopefully this thread will help someone else out that may be wondering why text they see in their presentation doesn’t show up anywhere when using many of the samples.

Thanks for your help.

Hi,

I am already planning to update the documentation in order to include pptx features. Your suggestion is good and i shall add some topics related to master slides.

Any other suggestions are welcome.