无法迭代 Shapes 集合
C# 和单词互操作, 我有一个带有一些文本框(msoTextBox 形状)的 Word 文档,问题是我无法使用下面的代码迭代形状集合:
foreach (Shape shape in WordDocument.Shapes)
{}
尽管在循环行中设置断点时我可以看到 WordDocument.Shapes.Count 返回 4 。
我注意到文本框是使用 open xml sdk 插入的
C# and word interop,
I have a word document with some textboxs (msoTextBox shapes), the problem that I can't iterate through the shapes collection with the code below :
foreach (Shape shape in WordDocument.Shapes)
{}
although when setting a breakpoint in the loop line I can see that WordDocument.Shapes.Count returns 4.
I note that textboxs are inserted using open xml sdk.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现使用文本框时存在问题。看看这个 解决方案。
I've found there's a problem when textboxes are used. Take a look at this solution.
来自代码项目:
从你所说的来看,你看起来像你做正确的事。
您能给我们错误 StackTrace 吗?
PS:我知道我的问题应该在评论中,但它不可读:)
From Code Project :
From what you said, you look like you do the right thing.
Can you give us the Error StackTrace ?
PS : I know my question should have been in the comments, but it wouldn't have been readable :)
因此,
将 : 替换
为:
效果很好。
So,
Replace :
By:
It's work perfectly.