Programming Powerpoint outside of Powerpoint

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>";
 
S

Shyam Pillai

Matt,
I can add notes through
code and they show up but any note that was added through powerpoint is
not
visible.
Your code is extracting text from the body placeholder. This will work
provided:
a) User has a slide image on the notes page. If slide image is missing
placeholder 1 is the notes shapes and not 2.
b) Notes page is entered only within the body placeholder.

Check the following:
a) Is placeholder(2) referencing the right shape.
b) Is the notes that is already present, entered in a placeholder or not.

I've tried the code in .Net and you can reference the notes page text
without any issues.


--
Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how


matt said:
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>";
 
M

matt

Shyam,

Thank you for the response. If I am pulling shapes from the notespage
object how is that I am not getting any notes? I had a loop running that
would check all the shapes for text and in most cases it found none, even on
placeholder (2) until after I had programmatically stored some of the data.
The notes I am looking for are the notes entered through the powerpoint
interface, i.e. at the bottom of the screen in powerpoint.
I've tried the code in .Net and you can reference the notes page text
without any issues
Were you using my code or some of your own? If it was some of your own can
you post it?

Thanks again.

Matt Sennate


Shyam Pillai said:
Matt,
I can add notes through
code and they show up but any note that was added through powerpoint is
not
visible.
Your code is extracting text from the body placeholder. This will work
provided:
a) User has a slide image on the notes page. If slide image is missing
placeholder 1 is the notes shapes and not 2.
b) Notes page is entered only within the body placeholder.

Check the following:
a) Is placeholder(2) referencing the right shape.
b) Is the notes that is already present, entered in a placeholder or not.

I've tried the code in .Net and you can reference the notes page text
without any issues.


--
Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how


matt said:
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>";

 
Top