Power Point failing in PowerPoint


#1

Here’s my problem or question. I take a PowerPoint collection of slides called V810.ppt. This contains 3 slides and it opens fine in Microsoft PowerPoint 2002. I use this as a base, run it though the enclosed code, and then try to open up the new PowerPoint. For some reason, it can’t open the new PowerPoint Slides, regardless if I save them to disk, or open them up in the IE browser. Any ideas? Here is the code.
----------------------------------------------------------------------------------------------------------

private void ExportToPowerPoint()
{
Random rand = new Random();
String myRandomNumber = rand.Next(0,99999).ToString(“00000”);
string formattedDate = null;

DateTime Today = DateTime.Now;
formattedDate = Today.ToString(“yyMMddhhmmss”);
String PowerPointFileNumber = “PW” + formattedDate + myRandomNumber + “.ppt”;
string filePathTemplatePPT = MapPath(".") + “\pptfiles\” + “V810.ppt”;
string filePathNewPPT = MapPath(".") + “\pptfiles\” + PowerPointFileNumber;
System.IO.FileStream fis = new System.IO.FileStream(filePathTemplatePPT,System.IO.FileMode.Open,System.IO.FileAccess.Read);
Presentation pres = new Aspose.PowerPoint.Presentation(fis);
fis.Close();

Slides slides = pres.Slides;
for (int i=0; i<slides.Count; i++)
{
// Set text of standard slide placeholders
Placeholders pholders = slides[i].Placeholders;
for (int j=0; j<pholders.Count; j++)
{
TextHolder th = pholders[j] as TextHolder;
if (th != null)
{
if (th.Text == “H1”)
th.Text = “Demo Presentation”;
else if (th.Text == “SH1”)
th.Text = “Aspose.PowerPoint.Template”;
else if (th.Text == “T1”)
{
switch (i)
{
case 1:
th.Text = “With Aspose.PowerPoint you can:\rOpen, read and save Microsoft PowerPoint presentations.”;
break;
case 2:
th.Text = “With Aspose.PowerPoint you can:\rChange standard text placeholders as well as custom text frames.”;
break;
case 3:
th.Text = “With Aspose.PowerPoint you can:\rReplace background pictures with any picture from presentation or new picture.”;
break;
}
}
}
}

// Set text for text frames
Shapes shapes = slides[i].Shapes;
for (int j=0; j<shapes.Count; j++)
{
TextFrame tf = shapes[j] as TextFrame;
if (tf != null)
{
if (tf.Text == “CT1”)
tf.Text = “Created on:”;
else if (tf.Text == “CT2”)
tf.Text = System.DateTime.Now.ToShortDateString();
else if (tf.Text == “P1”)
{
tf.Text = "Slide " + (i+1).ToString();
}
}
}
}

this.Response.ContentType = “application/vnd.ms-powerpoint”;
this.Response.AppendHeader(“Content-Disposition”,“attachment;filename=” + PowerPointFileNumber);
this.Response.Flush();
System.IO.Stream st = this.Response.OutputStream;
//
// Write the file
//
pres.Write(st);
this.Response.End();
}