跳到主要內容

如何在Word文檔中選擇所有表?

單擊Word中的一個表很容易 點選擇表符號 表格左上角的按鈕,如下圖所示。 您還可以使用“選擇表”功能選擇一個表。 但是,有什麼方法可以在Word文檔中一次快速選擇所有表嗎? 本文中的方法將幫助您理解它。 


使用VBA代碼選擇Word中的所有表

使用Kutools for Word輕鬆選擇Word中的所有表


使用VBA代碼選擇Word中的所有表

1。 按 其他 + F11 鍵打開 Microsoft Visual Basic應用程序 窗口。

2。 在開幕 Microsoft Visual Basic for Applications 窗口中,單擊 插入 > 模塊,然後將以下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多個方便的Word加載項, 免費試用,不受限制 60.

點擊 庫工具 > > 選擇表。 看截圖:

備註:要在選擇中選擇表,需要先選擇範圍,然後再應用功能。

然後,您可以看到如下結果。

在選擇中選擇表:

在整個文檔中選擇表:

如果您想免費試用該實用程序,請轉到 免費下載軟件 首先,然後按照上述步驟進行操作。


演示:使用Kutools for Word輕鬆選擇Word中的所有表


最佳辦公生產力工具

Kutools for Word - 透過 Over 提升您的文字體驗 100 顯著特點!

🤖 Kutools 人工智慧助手:用人工智慧改變你的寫作 - 生成內容  /  重寫文字  /  總結文件  /  查詢資料 基於文檔,全部在Word中

📘 文件掌握: 分頁  /  合併文件  /  以各種格式匯出選擇(PDF/TXT/DOC/HTML...)  /  批次轉換為PDF  /  將頁面匯出為圖像  /  一次列印多個文件...

內容編輯: 批量查找和替換 跨多個文件  /  調整所有圖片的大小  /  轉置表行和列  /  將表格轉換為文字...

🧹 輕鬆清潔: 移開 多餘的空間  /  分節符  /  所有標題  /  文本框  /  超鏈接  / 如需更多拆卸工具,請前往我們的 刪除組...

創意插入: 插入 千位分隔符  /  複選框  /  單選按鈕  /  QR Code  /  條碼  /  對角線表  /  公式標題  /  圖片說明  /  表格標題  /  多張圖片  / 發現更多 插入組...

🔍 精準選擇:精確定位 特定頁面  /    /  形狀  /  標題段落  / 增強導航功能 更多 選擇功能...

星級增強: 快速導航至任何位置  /  自動插入重複文字  /  在文檔視窗之間無縫切換  /  11 轉換工具...

???? 想嘗試這些功能嗎? Kutools for Word 提供了 60天免費試用,沒有任何限制! 🚀
 
Comments (10)
No ratings yet. Be the first to rate!
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
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations