C# 使用C循环浏览PowerPoint中的各个部分#

C# 使用C循环浏览PowerPoint中的各个部分#,c#,powerpoint,C#,Powerpoint,我尝试使用C#循环浏览Powerpoint中的各个部分 首先,我想检查属性ActivePresentation.HasSection,但得到一个错误。 然后ActivePresentation.SectionCount还显示一个错误-也是ActivePresentation.SectionProperties.Count 我的代码: if(oPresentation.HasSections == true) { for (int iSection = oPrese

我尝试使用C#循环浏览Powerpoint中的各个部分

首先,我想检查属性ActivePresentation.HasSection,但得到一个错误。 然后ActivePresentation.SectionCount还显示一个错误-也是ActivePresentation.SectionProperties.Count

我的代码:

if(oPresentation.HasSections == true)
{
                for (int iSection = oPresentation.SectionCount; iSection >0; iSection--)
                {
                    oPresentation.SectionProperties.Delete(iSection, false);
                }
            }
我可以使用C#with创建节

我可以使用c#with删除一个节

但有人知道如何循环浏览C#的PowerPoint中的部分并将其全部删除吗?如何检查演示文稿是否包含部分

在VBA中,这不是问题:

对于所有看起来一样的人,我自己也做了。我认为在使用变量后,无法直接访问oPresentation.SectionProperties.Count。也许有人能给我解释一下,我是新来的


错误说明了什么?oPresentation.HasSections引发错误CS1061:“Presentation”不包含“HasSections”的定义,并且找不到接受“Presentation”类型的第一个参数的扩展方法“HasSections”(是否缺少using指令或程序集引用?)oPresentation.SectionProperties.Count引发错误CS0428:无法将方法组“Count”转换为非委托类型“object”。您是否打算调用该方法?blaze_125:这与索引无关,即使在调试器模式下,oPresentation.SectionCount或oPresentation.SectionProperties.Count也会引发上述错误-它们只返回异常。
oPresentation.SectionProperties.AddBeforeSlide(1, false)
oPresentation.SectionProperties.Delete(2, false)
        PowerPoint.SectionProperties oSections = oPresentation.SectionProperties;

            if(oSections.Count > 0)
            {
                for (int iSection = oSections.Count; iSection > 0; iSection--)
                {
                    oSections.Delete(iSection, false);
                }
            }