Hi,
This is my code :
Microsoft.Office.Interop.PowerPoint.Application application = new Microsoft.Office.Interop.PowerPoint.Application();
string filePath = Server.MapPath(@"~\\Staf\\TestDoc\\" + strFileName.ToString());
Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = application.Presentations.Open(filePath,
Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse);
application.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
StringBuilder sb = new StringBuilder();
int page = pptPresentation.Slides.Count;
for (int num = 1; num < page + 1; num++)
{
Microsoft.Office.Interop.PowerPoint.Shapes slide = pptPresentation.Slides[num].Shapes;
//loop through all the shapes
foreach (Microsoft.Office.Interop.PowerPoint.Shape s in slide)
{
// Check to see if shape has a text frame and text
if (s.HasTextFrame == MsoTriState.msoTrue && s.TextFrame.HasText == MsoTriState.msoTrue)
{
if (s.Type.Equals(MsoShapeType.msoPlaceholder))
{
switch (s.PlaceholderFormat.Type)
{
case PpPlaceholderType.ppPlaceholderTitle:
sb.Append(s.TextFrame.TextRange.Text);
sb.Append(Environment.NewLine);
break;
case PpPlaceholderType.ppPlaceholderCenterTitle:
sb.Append(s.TextFrame.TextRange.Text);
sb.Append(Environment.NewLine);
break;
case PpPlaceholderType.ppPlaceholderBody:
sb.Append(s.TextFrame.TextRange.Text);
sb.Append(Environment.NewLine);
break;
case PpPlaceholderType.ppPlaceholderSubtitle:
sb.Append(s.TextFrame.TextRange.Text);
sb.Append(Environment.NewLine);
break;
case PpPlaceholderType.ppPlaceholderFooter:
sb.Append(s.TextFrame.TextRange.Text);
sb.Append(Environment.NewLine);
break;
case PpPlaceholderType.ppPlaceholderHeader:
sb.Append(s.TextFrame.TextRange.Text);
sb.Append(Environment.NewLine);
break;
default:
// don't need anything else
break;
}
}
}
}
}
string text = sb.ToString();
// Close word.
pptPresentation.Close();
System.Runtime.InteropServices.Marshal.ReleaseComObject(pptPresentation);
//wordApp.Application.Quit();
with my code, i can't read content of slide 2, 3, etc..
its just read slide 1 and all title of the ppt file. Whats wrong? What should i do?
thx,