获取内容'来自丰富的文本内容控制
我需要在Word中获得丰富的文本内容控制的“内容”,然后将该内容粘贴到另一个丰富的文本内容控制(格式)中。
这是我拥有的代码:
ActiveDocument.SelectContentControlsByTitle("original").Item(1).Range.FormattedText.Copy
ActiveDocument.SelectContentControlsByTitle("duplicate").Item(1).Range.Paste
哪个似乎可以使用,但是它将整个原始contentControl复制到(嵌套)重复的ContentControl ...而我只想单独使用格式的文本。
嵌套的原始和重复的内容
I need to get the 'contents' of a Rich Text Content Control in Word, and paste that content into another Rich Text Content Control (formatted).
Here's the code I have:
ActiveDocument.SelectContentControlsByTitle("original").Item(1).Range.FormattedText.Copy
ActiveDocument.SelectContentControlsByTitle("duplicate").Item(1).Range.Paste
Which seems to work, but it's copying the entire original ContentControl into (nested) the duplicate ContentControl... and I just want the formatted text alone.
original and duplicate content which is nested
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
Try:
与其使用VBA,不如映射内容控件。
对于丰富的文本控件,您需要映射XML零件。
Word Content Controls Greg Maxey by Greg Maxey
,而您自己可以做这个?有许多免费工具可以为您做。
它们具有不同的接口和功能,但所有这些都可以使您能够在文档中添加映射的内容控件,包括丰富的文本。
Rather than use vba for this, Map the Content Controls.
For Rich Text controls, you will need to map the XML parts.
Word Content Controls by Greg Maxey
While you can do this yourself, why? There are a number of free tools that will do it for you.
I am sure there are more out there but I have used the above tools. They have different interfaces and powers but all of them give you the ability to add a Mapped Content Control to a document, including a Rich Text one.