Taimoor Hassan

Taimoor Hassan

  • NA
  • 35
  • 8.4k

how i change font type,size of ppt file in C# *Desktop App)

Jun 29 2014 8:57 AM
i had already got the font name,size etc ..
this code extract the text and font size and name of ppt file .

now i want to change these properties pro-grammatically
 
string path = @"c:\users\taimoor\PPT\";
Microsoft.Office.Interop.PowerPoint.Application powerPointApp =
new Microsoft.Office.Interop.PowerPoint.Application();
PowerPoint.Presentations multiPresentations = powerPointApp.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation presentation = multiPresentations.Open(path + "Demo.pptx");
string presentationText = "";
 
string fonts = "";
for (int i = 0; i < presentation.Slides.Count; i++)
{
foreach (object item in presentation.Slides[i + 1].Shapes)
{
PowerPoint.Shape shape = (PowerPoint.Shape) item;
 
var slide = (PowerPoint.Slide) item;
foreach (var it in slide.Shapes)
{
if (shape.HasTextFrame == MsoTriState.msoTrue)
{
 
string c= shape.TextFrame.TextRange.Font.Size.ToString(CultureInfo.InvariantCulture);
textBox3.Text = c;
if (shape.TextFrame.HasText == MsoTriState.msoTrue)
{
PowerPoint.TextRange textRange = shape.TextFrame.TextRange;
string text = textRange.Text;
string font = Font.Name;
float size = Font.Size;
FontStyle style = Font.Style;
presentationText += text + " ";

// get the text size head and body 
float fontSize = shape.TextFrame.TextRange.Font.Size;

// get the length of body text 
int bodyLength = shape.TextFrame.TextRange.Length;

// get text of all body
string v = shape.TextFrame.TextRange.Text;