Adding notes

  • Thread starter Thread starter rajas
  • Start date Start date
R

rajas

I am using C++ to programmatically prepare powerpoint slides. I have
figured out how to add bullets and text on the slide - but do not know how
to add text in the notes part of the slide. Recording a macro to do this
did not give me any useful clues & I did not quite understand how to use the
NotesPage object of the slide (if indeed I am supposed to use that). Any
help is appreciated. Thanks
 
Rajas,
The Notespage object just as a slide object. So add a shape to the notespage
object and copy the desired text into it. If you need to place the text into
the notes body placeholder then iterate thru the shapes on the notespage and
locate the desired shape first.

Regards
Shyam Pillai
 
Thanks for the response - I was not sure that I had the right forum.

I thought it would be something like that, but have not had much luck.

What I want is to be able to add the needed text so that when the
presentation is printed (or viewed) in the mode of slide on top and the
notes at the bottom, the notes text will appear.

So I located the NotesPage of the slide, got the shapes collection & cycled
through the shapes to see if any of them would have a TextFrame to get a
TextRange to paste the text - none of them have a TextFrame. Do I have to
then create a TextFrame? I recorded a Macro to see what I get - I got
code to get the shape "rectangle 2" for the notes portion - I could not get
that code to work (I got an error message that I am looking outside the
range). Perhaps you have an example.
 
Thanks for the response - I was not sure that I had the right forum.

I thought it would be something like that, but have not had much luck.

What I want is to be able to add the needed text so that when the
presentation is printed (or viewed) in the mode of slide on top and the
notes at the bottom, the notes text will appear.

That would be Notes view.

Try:

Sub FindTheNotesText()

Dim lngSlideIndex As Long
Dim oSh As Shape

lngSlideIndex = 1 ' for demo purposes only

For Each oSh In ActivePresentation.Slides(lngSlideIndex).NotesPage.Shapes
If oSh.Type = msoPlaceholder Then
If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then
oSh.TextFrame.TextRange.Text = _
"Congratulations, Rajas! You found me!"
End If
End If
Next oSh

End Sub
 
Steve,

I guess that did not do it - here is my C++ equivalent of your code. It does add the text, but adds it in the slide main body, not the notes area. - Even though I am supposedly getting the NotesPage

MSPpt::DocumentWindow win(app.GetActiveWindow());

TRACE("View type number is %d\n",win.GetViewType());

win.SetViewType(3);//notes view

MSPpt::SlideRange sr(sld.GetNotesPage());

MSPpt::Shapes shps2(sr.GetShapes());

shps2 = sld.GetShapes();

int cnt = shps2.GetCount() +1; //I get only 2 shapes

for (int i = 1; i < cnt ; i++)

{

MSPpt::Shape shp(shps2.Item(COleVariant(long(i))));

if (shp.GetType() == long(14) ) {//place holder

MSPpt::PlaceholderFormat pf(shp.GetPlaceholderFormat());

if (pf.GetType() == long(2)) { //placeholderbody

MSPpt::TextFrame tf(shp.GetTextFrame());

MSPpt::TextRange tr(tf.GetTextRange());

str = "*** Testing ***";

tr.InsertAfter(str);

tr.InsertAfter("\r\n");

}

}

}

win.SetViewType(9);
 
Thanks Steve,

I found my problem - I was changing the view to NotesView & that was not
needed. When I kept the view in the normal mode, NotesPage found the notes
page & your code (the C++ equivalent) worked.

Once again Thanks
 
Thanks Steve,

I found my problem - I was changing the view to NotesView & that was not
needed. When I kept the view in the normal mode, NotesPage found the notes
page & your code (the C++ equivalent) worked.

Ah, great. Ignore my other reply then, in case I forget to delete it.
Note that you shouldn't have to change the view to add text to a shape, though.
You can simply reference it through the object model (and get faster-running
code as a result, since PPT doesn't need to redraw anything)
 
Back
Top