Hi Shakeel,
What is a slide with a placeholder in it? Is that merely a slide w/ a textbox (and some text put into it?)
My question is related to the program below. I am trying to create a presentation called "pres", which I will write to the powerpoint slide "helloworld.ppt". The first slide of pres is the first slide of the presentation pres1, the second slide is the first slide of presentation pres2, the this is the first slide of the presentation pres3.
The remaining slides (i+2=4,...,15) of pres are as follows. Take a copy of the (single-slide) presentation "TemplateMRCAgain.ppt", alter copy of that slide, and then pop it at the end. Specifically, replace the text "Top three categories of customer penetration for Houehold type..." in the textbox of "TemplateMRCAgain.ppt" with something else, that depends on i.
The program compiles fine, but when I try to run, I get the error message "NullReferenceException was unhandled". Any way to fix this?
Thanks!
Mike
namespace ConsoleApplication1
{
class AIPOutput
{
static void Main(string[] args)
{
Slide[] slideDeck = new Slide[14];
string[] Ourtitle = new String[14];
Portion[] por = new Portion[14];
int i = 0;
Ourtitle[0] = "Processing Summary";
Ourtitle[1] = "Region";
Ourtitle[2] = "Age Range";
Ourtitle[3] = "Income";
Ourtitle[4] = "Gender";
Ourtitle[5] = "Marital Status";
Ourtitle[6] = "Household Type";
Ourtitle[7] = "Number of Children";
Ourtitle[8] = "Occupation";
Ourtitle[9] = "Dwelling Type";
Ourtitle[10] = "Length of Residence";
Ourtitle[11] = "Home Ownership";
Ourtitle[12] = "eConsumer Decile";
Ourtitle[13] = "Small Office/Home Office (SOHO)";
Presentation pres1 = new Presentation("C:\\Documents and Settings\\mcapalbo\\Desktop\\AIP\\CompletedAIPs\\Title.ppt");
Presentation pres = pres1;
Presentation pres2 = new Presentation("C:\\Documents and Settings\\mcapalbo\\Desktop\\AIP\\CompletedAIPs\\Waterfall.ppt");
Presentation pres3 = new Presentation("C:\\Documents and Settings\\mcapalbo\\Desktop\\AIP\\CompletedAIPs\\RegionSlide.ppt");
Presentation pres4 = new Presentation("C:\\Documents and Settings\\mcapalbo\\Desktop\\AIP\\CompletedAIPs\\TemplateMRCAgain.ppt");
Slide slide = pres2.GetSlideByPosition(1);
System.Collections.SortedList slist = new System.Collections.SortedList();
pres2.CloneSlide(slide, pres.Slides.LastSlidePosition + 1, pres, slist);
Slide slide3 = pres3.GetSlideByPosition(1);
System.Collections.SortedList slist3 = new System.Collections.SortedList();
pres3.CloneSlide(slide3, pres.Slides.LastSlidePosition + 1, pres, slist3);
for (i = 2; i < 14; i++)
{
/* Make slide title */
Slide slide4 = pres4.GetSlideByPosition(1);
Aspose.Slides.Rectangle rectTitle = slide4.Shapes.AddRectangle(240, 60, 4500, 200);
rectTitle.LineFormat.ShowLines = false;
rectTitle.AddTextFrame("Demographic Profile: " + Ourtitle[i]);
TextFrame titleMadeForSlide = rectTitle.TextFrame;
titleMadeForSlide.Paragraphs[0].Portions[0].FontBold = true;
/* Make slide textbox */
TextHolder th = (TextHolder)slide4.Placeholders[1];
if (th.Text.Equals("Top three categories of customer penetration for Household Type are Adult Male and Adult Female Present With Children, Adult Male Present With Children, and Adult Male & Adult Female Present"))
{
th.Paragraphs[0].Portions[0].Text = "The top category for customer penetration for " + Ourtitle[i] + " is";
}
th.Paragraphs[0].Portions[0].FontBold = true;
/* Put slide in presentation */
System.Collections.SortedList slist4 = new System.Collections.SortedList();
pres4.CloneSlide(slide4, pres.Slides.LastSlidePosition +1, pres, slist4);
}
pres.Write("C:\\Documents and Settings\\mcapalbo\\desktop\\helloworld.ppt");
}
}