Odd Issue

Greetings,

I'm having an odd issue with a ppt template file. Our customer asked us to add a graphic to the template we use, which I thought would be very easy to do. When I copied the graphic from the template they supplied into the template I created the colors change from Red/White/Blue to Green which I don't understand.

I next tried using their template but I get an exception error when I try to use it. Appartantly the file they sent me doesn't have the any textframes in it. Below is the code I'm using and I'm getting the exception on the tf = Shapes(0).Textframe line.

Dim License As New Aspose.powerpoint.License

License.SetLicense(ConfigurationSettings.AppSettings("Path") & "Aspose.PowerPoint.lic")

'Dim fis As System.IO.FileStream = New System.IO.FileStream(MapPath(".") + "\\ai2.ppt", IO.FileMode.Open, System.IO.FileAccess.Read)

Dim fis As System.IO.FileStream = New System.IO.FileStream(MapPath(".") + "\\ait2.ppt", IO.FileMode.Open, System.IO.FileAccess.Read)

Dim pres As Presentation = New Presentation(fis)

fis.Close()

Dim slides As Slides = pres.Slides

Dim Shapes As Shapes

Dim tf As TextFrame

Shapes = slides(0).Shapes

'AINumber

tf = Shapes(0).TextFrame

tf.Paragraphs(0).Portions(0).FontBold = True

tf.Paragraphs(0).Portions(0).FontHeight = 18

tf.Paragraphs(0).Alignment = TextAlignment.Center

tf.Paragraphs(0).Portions(0).Text = AINumber

I am attaching the two template ppt files I'm tryng to work with. If I use our template (the one with the Green image) things work fine. If there's anyway to just fix the logo on my template I'd be happy with that solution. According to Visual Studio I'm using 2.0.0.0 of the dll if that matters.

Thanks in advance for any assistance you can provide.

Dear Zack,

At first, I’d recommend to update Aspose.PowerPoint with Aspose.Slides.

The main your problem is this line:
Shapes = slides(0).Shapes

Slides are not sorted in the Presentation.Slides collection so
slides(0) can return random slide in different presentations.

In your (green) template this code returns shapes from the first slide but
in customer’s (red/blue) template it try to return shapes from master or
second slide. And of course Shape(0) can’t be found.

You should use GetSlideByPosition function instead.
Shapes = pres.GetSlideByPosition(1)