C# 中的 PowerPoint 笔记 [英] PowerPoint Notes in C#

查看:68
本文介绍了C# 中的 PowerPoint 笔记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想阅读用 C# 编写的 PowerPoint 幻灯片的注释.关注片段对我有用.

I want to read the notes of a PowerPoint Slide in C#. Following Snippet works for me.

slide.NotesPage.Shapes[2].TextFrame.TextRange.Text

但是,这不适用于某些演示文稿.然后它会抛出超出范围"异常.

However, this doesn't work for some presentations. Then it throws an "Out of range" exception.

索引2是什么意思?有没有其他方法可以做到这一点?

What ist the meaning of index 2? Are there any alternative to do this?

推荐答案

您不能假设备注文本占位符将位于任何特定索引处,甚至不能假设它会有特定名称.这是 VBA 中的一个简单函数,它返回幻灯片的注释文本占位符:

You can't assume that the notes text placeholder will be at any specific index or even that it'll have a specific name. Here's a simple function in VBA that returns the notes text placeholder for a slide:

Function NotesTextPlaceholder(oSl As Slide) As Shape

Dim osh As Shape

For Each osh In oSl.NotesPage.Shapes

    If osh.Type = msoPlaceholder Then
        If osh.PlaceholderFormat.Type = ppPlaceholderBody Then
            ' we found it
            Set NotesTextPlaceholder = osh
            Exit Function
        End If
    End If

Next

结束函数

这篇关于C# 中的 PowerPoint 笔记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆