跳到主要内容

如何在Word文档中选择所有表?

作者:孙 最后修改时间:2024-07-11

单击Word中的一个表很容易 点选择表符号 表格左上角的按钮,如下图所示。您也可以使用选择表格功能选择表格。但是,有没有办法快速一次选择Word文档中的所有表格?在本文中,我们将介绍两种技术来帮助您快速选择Word中的所有表格。


使用VBA代码选择Word中的所有表

使用 Kutools for Word 轻松选择所有表格


使用VBA代码选择Word中的所有表

1。 按 其他 + F11 键打开 Microsoft Visual Basic应用程序 窗口。

2。 在开幕 Microsoft Visual Basic应用程序 窗口中,单击 插页 > 模块,然后将以下VBA代码复制并粘贴到“模块”窗口中;

VBA代码:选择当前文档中的所有表:

Sub selecttables()
Dim mytable As Table

For Each mytable In ActiveDocument.Tables
mytable.Range.Editors.Add wdEditorEveryone
Next
ActiveDocument.SelectAllEditableRanges (wdEditorEveryone)
ActiveDocument.DeleteAllEditableRanges (wdEditorEveryone)
End Sub

3。 按 F5 运行代码的关键

然后,立即在当前文档中选择所有表。


使用 Kutools for Word 轻松选择 Word 中的所有表格

与使用 VBA 代码选择文档中的所有表格相比,Kutools for Word 的 选择表 实用程序非常方便。 您可以使用此功能选择所选内容或整个文档中的表格。 请执行以下操作:

Kutools for Word, 配备人工智能 🤖,提供 100 多种方便的功能来简化您的任务。

点击 库工具 > > 选择表。 看截图:

备注:要在选择中选择表,需要先选择范围,然后再应用功能。

然后,您可以看到如下结果。

在选择中选择表:

在整个文档中选择表:

如果您想免费试用该实用程序,请转到 免费下载软件 首先,然后按照上述步骤进行操作。


演示:使用 Kutools for Word 轻松选择 Word 中的所有表格


最佳办公生产力工具

Kutools for Word - 通过 Over 提升您的文字体验 100 显着特点!

🤖 Kutools 人工智能助手:用人工智能改变你的写作 - 生成内容  /  重写文本  /  总结文件  /  快速获得答案,全部在Word中

📘 文档掌握: 分页  /  合并文件  /  以各种格式导出选择(PDF/TXT/DOC/HTML...)  /  批量转换为PDF  /  将页面导出为图像  /  一次打印多个文件...

内容编辑: 批量查找和替换 跨多个文件  /  调整所有图片的大小  /  转置表行和列  /  将表格转换为文字...

🧹 轻松清洁: 移开 多余的空间  /  分节符  /  所有标题  /  文本框  /  超链接  / 如需更多拆卸工具,请前往 删除组...

创意插入: 插 千位分隔符  /  复选框  /  单选按钮  /  扫码支付  /  条码  /  对角线表  /  公式标题  /  图片说明  /  表标题  /  多张图片  / 发现更多 插入组...

🔍 精准选择:精确定位 特定页面  /    /  形状  /  标题段落  / 增强导航功能 更多 选择功能...

星级增强: 导航到任何位置  /  自动插入重复文本  /  在文档窗口之间切换  /  11 转换工具...

👉 想要尝试这些功能吗?立即下载 Kutools for Word 并体验不同之处! 🚀
 
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How do i only select the tables and figure captions. All my captions have reverted back to normal style. I had captioned all of them but now they are all not linked to the caption
This comment was minimized by the moderator on the site
Very nice method. Thank you
This comment was minimized by the moderator on the site
It seeems that this macros does not work in Word 2016
This comment was minimized by the moderator on the site
It works in Word 2016. What error are you getting?
This comment was minimized by the moderator on the site
I understand already. For correct work macros cursor must to be not in table when you call macros. Thank you.
This comment was minimized by the moderator on the site
There are multiple tables in a document (about 200). I want to select all these tables only and paste them in a new document in the table format. When I select the tables as per above procedure then during paste operation it pastes them as text and not as table. Can you please help me?
This comment was minimized by the moderator on the site
The following modified code selects all tables, except tables having only one row: Sub SelAllTbls() ActiveDocument.DeleteAllEditableRanges (-1) Dim Tbl As Table For Each Tbl In ActiveDocument.Tables If Tbl.Rows.Count > 1 Then Tbl.Range.Editors.Add (-1) End If Next ActiveDocument.SelectAllEditableRanges (-1) ActiveDocument.DeleteAllEditableRanges (-1) End Sub The following code select only the header rows: Sub selallHeaders() On Error Resume Next ActiveDocument.DeleteAllEditableRanges (-1) Dim Tbl As Table For Each Tbl In ActiveDocument.Tables Tbl.Rows(1).Range.Editors.Add (-1) Next ActiveDocument.SelectAllEditableRanges (-1) ActiveDocument.DeleteAllEditableRanges (-1) End Sub I have many more such codes that select last rows, all bullets, small / long paras, etc. Watch my following video: https://www.youtube.com/watch?v=p_ZhufliFw8
This comment was minimized by the moderator on the site
Wonderful I got the solution by using the VBA code. Thank you so much
This comment was minimized by the moderator on the site
Nifty code at first but it definitely corrupted a bunch of tables in Word 2010. Screwed up my file pretty good and had to revert back to an earlier version. Be wary!
This comment was minimized by the moderator on the site
excellent macro and very easy
This comment was minimized by the moderator on the site
thank you so much he is good program but after few days stopped and require password and user name
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations