从多个 Microsoft Word 文件中提取文本框数据
我有一个文件夹,里面有 40-50 个 Microsoft Word 文档。
每个Word文档的结构如下: - 有多个表有两列 - 第二列包含问题,每个问题末尾有一个唯一标识符(例如“<#Q123#>”) - 在包含问题的同一单元格中,唯一标识符后面有一个文本框,其中包含问题的答案
我正在尝试在 Microsoft Word 中开发一个宏,它将打开文件夹中的每个 Word 文档,搜索文本框,然后将其粘贴到包含宏的新文件中。
如果可以将文本框中的数据提取到 Excel 文件中,而不是将文本框复制并粘贴到 Word 文档中,那就更好了,但我不确定这是否可能(因为某些文本框可能包含
I have a folder with 40-50 Microsoft Word documents.
Each Word document is structured as follows:
- There are multiple tables with two columns
- The second column contains the question, and at the end of each question there is a unique identifier (such as "<#Q123#>")
- In the same cell that contains the question, there is a text box after the unique identifier which contains the answer to the question
I am trying to develop a macro in Microsoft Word that will open each Word document in the folder, search for the text box that is immediately after the specified unique identifier, and paste it into the new file that has the macro.
If it were possible to extract the data from within the text boxes into an Excel file rather then copying and pasting the text boxes into a Word document, that would be preferrable, but I wasn't sure if that were possible (since some of the text boxes might contain
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
列出的答案这里和此处 可以向您展示如何获取文件夹中的所有文件。
以下 VBA 代码可用于检索表第二列中的文本以及同一单元格中形状(文本框)中的文本。如果在表格单元格中找不到形状(文本框),则使用
On Error Resume Next
语句来保持代码运行。The answers listed here and here can show you how to get all the files in your folder.
The following VBA code can be used to retrieve the text in the 2nd column of the table, as well as the text in the shape(textbox) that is in that same cell. The
On Error Resume Next
statement is in place to keep the code running if no shape(textbox) is found in the table cell.