Extract Powerpoint Speaker Notes in C#

  • Thread starter Christian Herlambang
  • Start date
C

Christian Herlambang

Hello,

After I've had some research in microsoft.public.powerpoint, I found
this code written by Shyam Pillai to extract Powerpoint speaker notes to
a text file.

--
Sub ReadText()
Dim shp As Shape
Dim sld As Slide

Open "c:\abc.txt" For Output As #1
On Error Resume Next
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
Print #1, shp.TextFrame.TextRange
End If
End If
Next
Next
Close #1
End Sub
--

It works well in VBA. Now I want to port it to C# .NET. Not having
enough experience and knowledge in C# .NET, I'd like to ask anyone who
can help me translating that code.

Michael Brown wrote in:
http://groups.google.com/groups?q=m...=#[email protected]&rnum=1

That this code should do the job:
--
foreach (PowerPoint.Shape sh in
ppPres.Slides.Range(curSlide).NotesPage.Shapes)
if (MsoTriState.msoTrue == sh.HasTextFrame)
if (MsoTriState.msoTrue == sh.TextFrame.HasText)
Console.WriteLine(sh.TextFrame.TextRange.Text);
--

But I couldn't make it running in my program. Any Hint?

Thank you in advanced.


Christian Herlambang
 
C

Christian Herlambang

Christian said:
After I've had some research in microsoft.public.powerpoint, I found
this code written by Shyam Pillai to extract Powerpoint speaker notes to
a text file.

--
Sub ReadText()
Dim shp As Shape
Dim sld As Slide

Open "c:\abc.txt" For Output As #1
On Error Resume Next
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
Print #1, shp.TextFrame.TextRange
End If
End If
Next
Next
Close #1
End Sub
--

It works well in VBA. Now I want to port it to C# .NET. Not having
enough experience and knowledge in C# .NET, I'd like to ask anyone who
can help me translating that code.
I just solved the problem.

Code in C# .NET

foreach(PowerPoint.Slide sld in oPPT.ActivePresentation.Slides)
foreach(PowerPoint.Shape shp in sld.Shapes)
if(Microsoft.Office.Core.MsoTriState.msoTrue == shp.HasTextFrame)
if(Microsoft.Office.Core.MsoTriState.msoTrue == shp.TextFrame.HasText)
Console.WriteLine(sh.TextFrame.TextRange.Text);

regards,

Christian Herlambang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top