Quick start



I am having problems with the quick start code www.aspose.com/Wiki/default.aspx/Aspose.Slides/QuickStart.html.

I'm using visual studio 2005, C# and have added the component reference and namespace and a straight copy and paste of the source code for the button event handler. On pressing the button it generates the following error:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 33: // Test to insure that the correct placeholder is selected
Line 34: if (th.Text == "PH1")
Line 35: {
Line 36: // Set text of the slide placeholder

Any help would be appreciated.

Thanks in advance



Did you follow first step?

To begin with you need a Power Point Presentation file (.ppt) in which
to modify.

I have created a simple one slide presentation with a single
placeholder containing the text “PH1”.


Hi Alexey

Thanks for the quick reply. Yes i've created the powerpoint file with one placeholder and checked the path is correct.




This quick start example shows how to find placeholder with existing text and change it.
Did you write “PH1” in this placeholder?


Yes, I used the title slide template for a single placeholder and wrote PH1 in the placeholder.


It looks like in your case slide doesn’t contain TextHolders.
Probably your presentation has title master slide in Slides[0] position.
Try to use GetSlideByPosition function instead.

Placeholders pholders = pres.GetSlideByPosition(1).Placeholders;
TextHolder th = pholders[0] as TextHolder;
if (th != null && th.Text == “PH1”)
th.Paragraphs[0].Portions[0].Text = "Hello World ";


Thanks for that code suggestion, it's helped greatly. The application now prompts for opening/saving of the powerpoint file and on opening reveals the original placeholder with PH1 text and the watermark evaluation message just below. I'll have another look at why the text isn't replacing.

Thanks for the excellent support.!




You can attach your source ppt file with sources and I will check what is wrong.


Managed to crack it.

Despite checking the demo.ppt file several times, the placeholder seems to have been replaced by a PH1 text field at some point. It now correctly displays "Hello World" on execution with the code fix you suggested above.

However, if I use the original code it still displays the error "Exception Details: System.NullReferenceException: Object reference not set to an instance of an object." I've attached the source prior to the code suggested above and ppt file.

I'm more than happy to use the work around suggested.