gpt4 book ai didi

c# - 使用 C# 在 PowerPoint 中循环遍历各个部分

转载 作者:行者123 更新时间:2023-12-04 17:46:59 28 4
gpt4 key购买 nike

我尝试使用 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# 创建部分

oPresentation.SectionProperties.AddBeforeSlide(1, false)

我可以使用 c# 删除一个部分

oPresentation.SectionProperties.Delete(2, false)

但是有人知道如何通过 C# 循环遍历 PowerPoint 中的部分并将它们全部删除吗?如何检查演示文稿是否有部分?

在 VBA 中这不是问题: https://code.msdn.microsoft.com/office/PowerPoint-2010-Insert-b6f1e012

最佳答案

对于所有看起来都一样的人,我自己搞定了。我认为没有直接访问 oPresentation.SectionProperties.Count - 在使用它工作的变量之后。也许有人可以向我解释,我是这个 C# 的新手。

        PowerPoint.SectionProperties oSections = oPresentation.SectionProperties;

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

关于c# - 使用 C# 在 PowerPoint 中循环遍历各个部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48067606/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com