Hi,
Hi,
public static void ReplaceText(){string dataDir = @“C:\Presentations”;//Instantiate a Presentation object that represents a PPT filePresentation pres = new Presentation(dataDir + “FindAndReplace.ppt”);//Slides slides = pres.Slides;//Accessing a slide using its slide positionint slideCount = pres.Slides.Count;Paragraph para = null;Portion portion = null;for (int i = 1; i <= pres.Slides.Count; i++){Slide slide = pres.GetSlideByPosition(i);int placeholdersCount = slide.Placeholders.Count;for (int j = 0; j < placeholdersCount; j++){//Accessing the first placeholder in the slide and typecasting it as a text holderTextHolder th = (TextHolder)slide.Placeholders[j];//Comparing the text in text holder to find a specific text holder. If the//text matches then replace the text inside that text holderfor (int k = 0; k < th.Paragraphs.Count; k++){para = th.Paragraphs[k];String st1,st2;for (int x = 0; x < para.Portions.Count; x++){portion = para.Portions[x];portion.Text=portion.Text.Replace("", System.DateTime.Today.ToShortDateString());portion.Text = portion.Text.Replace("", “Motorola”);portion.Text = portion.Text.Replace("", “AmSouth/Harbert Plaza”);portion.Text = portion.Text.Replace("", “Birmingham”);portion.Text = portion.Text.Replace("", “Albama”);portion.Text = portion.Text.Replace("", “35203”);portion.Text = portion.Text.Replace("", “Allen Border”);portion.Text = portion.Text.Replace("", System.DateTime.Today.AddDays(-10).ToShortDateString());portion.Text = portion.Text.Replace("", System.DateTime.Today.AddDays(-1).ToShortDateString());portion.Text = portion.Text.Replace("", “Max”);}}}}//Writing the presentation as a PPT filepres.Write(dataDir + “FindAndReplace out.ppt”);}
Hi Mudassir ,
Hi,
Hi Mudassir,