-1

I need to determine if any new ContentControls were inserted into a Word 2010 (docx) document after a paste so that I can create a new XML node to which I can map them.

The way I see it, there are two challenges:

  1. How do I capture the paste event? (I've seen suggestions to detect a button combination, or toolbar press, etc.)
  2. What is the best way to check the pasted content for controls? (Should I check the clipboard, a range in the document, etc.)

Once I have a collection of the new ContentControls, I already have functions that can check for prior existence, and create new mappings if the ContentControls are new. I just need to be able to detect the presence of a new ContentControl when it is inserted.

****UPDATE****

I have not been able to successfully check the clipboard contents for ContentControls. I cannot enumerate throught the clipboard data to find the controls.

4

1 回答 1

0

有一个内置的事件处理程序在添加 ContentControl 后触发:

Private Sub Document_ContentControlAfterAdd(ByVal NewContentControl As ContentControl, ByVal InUndoRedo As Boolean)

将事件处理程序放在 ThisDocument 模块中(您可以在 ThisDocument 内部时从 VBA 下拉菜单中自动创建它)。

如何添加控件并不重要(粘贴和插入命令都会触发事件)。每个新的 ContentControl 都会触发该事件。我可以测试每一个,看看它是否已经在文档中。

奇迹般有效。

于 2015-09-16T19:32:39.340 回答