Hi…
I have hundreds of text that I need to replace. How can replace the text with a multi-line text with the Newline?
I have text like TITLE
I need to replace it with text that looks like this
MY DOCUMENT TITLE
March 3, 2012
DRAFT
thanks in advance
I’m still not clear on what I have to do.
Can you please provide an example.
thank you
Hi Jon,
Please use the code snippet below for your further guidance.
String path = “C:\Users\Mudassir\Downloads\”;
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation(path+“TITLE.ppt”);
//Accessing a slide using its slide position
Slide slide = pres.GetSlideByPosition (1);
TextFrame tf = null;
foreach (Shape shape in slide.Shapes)
{
tf = shape.TextFrame;
if (tf != null && tf.Text != “”)
{
if(tf.Text.Equals (“TITLE”))
{
//The following line of code will replace text on text frame level
//Replacing text with n multi lines with carriage return will have n paragraphs
// tf.Text = “MY DOCUMENT TITLE\n March 3, 2012\nDRAFT”;
//Use above or use below code
//The following line of code will replace text on paragraph level and all text
//even of multiple lines will be accomodated in multiple lines using soft enter
tf.Paragraphs [0].Text = “MY DOCUMENT TITLE\v March 3, 2012\vDRAFT”;
}
}
}
//Writing the presentation as a PPT file
pres.Write(path+“modified.ppt”);
Many Thanks,