COM 字 -->获取所有内容控件
我想获取Word文档的所有ContentControl。目前我使用以下函数来执行此操作。
private static List<ContentControl> GetAllContentControls(Document wordDocument)
{
if (null == wordDocument)
throw new ArgumentNullException("wordDocument");
List<ContentControl> ccList = new List<ContentControl>();
Range rangeStory;
foreach (Range range in wordDocument.StoryRanges)
{
rangeStory = range;
do
{
try
{
foreach (ContentControl cc in rangeStory.ContentControls)
{
ccList.Add(cc);
}
}
catch (COMException) { }
rangeStory = rangeStory.NextStoryRange;
}
while (rangeStory != null);
}
return ccList;
}
问题是在文本字段中也获取内容控件。
I want to get all ContentControls of a Word-Document. Currently I use following function to do this.
private static List<ContentControl> GetAllContentControls(Document wordDocument)
{
if (null == wordDocument)
throw new ArgumentNullException("wordDocument");
List<ContentControl> ccList = new List<ContentControl>();
Range rangeStory;
foreach (Range range in wordDocument.StoryRanges)
{
rangeStory = range;
do
{
try
{
foreach (ContentControl cc in rangeStory.ContentControls)
{
ccList.Add(cc);
}
}
catch (COMException) { }
rangeStory = rangeStory.NextStoryRange;
}
while (rangeStory != null);
}
return ccList;
}
The Problem is to get Contentcontrols in text-fields, too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了它
I got it