M
matt
Hi,
I am trying to build a web application that reads the contents of an
uploaded ppt file. For the most part everything is working well. However,
the notespage is not accessible from the object model. I have followed all
the directions on the few pages that exist on the web concerning notespages.
All of them seem to work from a ppt macro, but Microsoft says that .Net has
access to the office COM objects, which is true but somethings do not work
the same as from the macro editor. I am including some code and hopefully i
can get some assistance.
This code is in c# and is simply a display of all the info in each slide in
the presentation. However the notes do not show. I can add notes through
code and they show up but any note that was added through powerpoint is not
visible.
PowerPoint.Application ppApp = null;
PowerPoint.Presentation ppPresentation = null;
PowerPoint.Slides ppSlides = null;
PowerPoint.Slide ppSlide = null;
try
{
ppApp = new PowerPoint.ApplicationClass ();
ppPresentation = ppApp.Presentations.Open (Server.MapPath ("/data/slides/")
+
file,Office.MsoTriState.msoFalse,Office.MsoTriState.msoFalse,Office.MsoTriState.msoFalse);
ppSlides = ppPresentation.Slides;
// process each slide
string pp = "";
for (int i = 1; i <= ppSlides.Count; ++i)
{
ppSlide = ppSlides;
pp += "<div><b>Name:</b> " + ppSlide.Name + "</div>";
pp += "<div><b>Notes:</b> " +
ppPresentation.Slides.NotesPage.Shapes.Placeholders[2].TextFrame.TextRange.Text + "</div>";
pp += "<div><b>SlideID:</b> " + ppSlide.SlideID + "</div>";
pp += "<div><b>SlideIndex:</b> " + ppSlide.SlideIndex + "</div>";
pp += "<div><b>SlideNumber:</b> " + ppSlide.SlideNumber + "</div>";
pp += "<div><b>HyperLinks:</b> <ol>";
foreach (PowerPoint.Hyperlink hl in ppSlide.Hyperlinks)
pp += "<li>" + hl.TextToDisplay;
pp += "</ol></div>";
pp += "<div><b>Tags:</b><ol>";
pp += "<div><b>Shapes:</b><ol>";
foreach (PowerPoint.Shape sh in ppSlide.Shapes)
{
pp += "<li>" + sh.Name + " (" + sh.Type + ")";
pp += sh.TextFrame.HasText;
if (sh.TextFrame.HasText == Office.MsoTriState.msoTrue)
pp += sh.TextFrame.TextRange.Text;
}
pp += "</ol></div>";
I am trying to build a web application that reads the contents of an
uploaded ppt file. For the most part everything is working well. However,
the notespage is not accessible from the object model. I have followed all
the directions on the few pages that exist on the web concerning notespages.
All of them seem to work from a ppt macro, but Microsoft says that .Net has
access to the office COM objects, which is true but somethings do not work
the same as from the macro editor. I am including some code and hopefully i
can get some assistance.
This code is in c# and is simply a display of all the info in each slide in
the presentation. However the notes do not show. I can add notes through
code and they show up but any note that was added through powerpoint is not
visible.
PowerPoint.Application ppApp = null;
PowerPoint.Presentation ppPresentation = null;
PowerPoint.Slides ppSlides = null;
PowerPoint.Slide ppSlide = null;
try
{
ppApp = new PowerPoint.ApplicationClass ();
ppPresentation = ppApp.Presentations.Open (Server.MapPath ("/data/slides/")
+
file,Office.MsoTriState.msoFalse,Office.MsoTriState.msoFalse,Office.MsoTriState.msoFalse);
ppSlides = ppPresentation.Slides;
// process each slide
string pp = "";
for (int i = 1; i <= ppSlides.Count; ++i)
{
ppSlide = ppSlides;
pp += "<div><b>Name:</b> " + ppSlide.Name + "</div>";
pp += "<div><b>Notes:</b> " +
ppPresentation.Slides.NotesPage.Shapes.Placeholders[2].TextFrame.TextRange.Text + "</div>";
pp += "<div><b>SlideID:</b> " + ppSlide.SlideID + "</div>";
pp += "<div><b>SlideIndex:</b> " + ppSlide.SlideIndex + "</div>";
pp += "<div><b>SlideNumber:</b> " + ppSlide.SlideNumber + "</div>";
pp += "<div><b>HyperLinks:</b> <ol>";
foreach (PowerPoint.Hyperlink hl in ppSlide.Hyperlinks)
pp += "<li>" + hl.TextToDisplay;
pp += "</ol></div>";
pp += "<div><b>Tags:</b><ol>";
pp += "<div><b>Shapes:</b><ol>";
foreach (PowerPoint.Shape sh in ppSlide.Shapes)
{
pp += "<li>" + sh.Name + " (" + sh.Type + ")";
pp += sh.TextFrame.HasText;
if (sh.TextFrame.HasText == Office.MsoTriState.msoTrue)
pp += sh.TextFrame.TextRange.Text;
}
pp += "</ol></div>";