Word find all tables

  • Hi,

    In Word, there is no such settings or button to directly select all tables at once.

    Maybe some codes can be used for your requirement. I found the following article provide a code about select all tables in a document:

    https://www.extendoffice.com/documents/word/639-word-select-all-tables.html

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please
    make sure that you completely understand the risk before retrieving any suggestions from the above link.

    It indicates that we can use a VBA code to select all tables in the document :

    Step 1: Press “Alt-F11” to open the Microsoft Visual Basic for Application window;
    Step 2: Click Module on the Insert tab, copy and paste the following VBA code into the Module window;

    Sub selecttables()
     Dim mytable As Table
     Application.ScreenUpdating = False

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

    Step 3: Save the VBA file and then close the Module window;
    Step 4: Click Run Macro on the Run tab;
    Step 5: Select the saved VBA file and click Run button.

    If you still have any further issue about it, it is better to ask a question in

    Word for Developers forum for more help.


    Regards,

    Winnie Liang


    Please remember to
    mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact
    tnmff@microsoft.com.

    • Proposed as answer by

      Monday, October 10, 2016 2:50 AM

    • Marked as answer by
      Winnie LiangMicrosoft contingent staff
      Tuesday, October 11, 2016 10:02 AM

  • It is easy to select a table in Word by clicking the dot-select-table-symbol button on the upper left corner of the table as below screenshot shown. You can also select a table with the Select Table feature. However, is there any way to quickly select all tables at once in Word document? The methods in this article will help you to get through it. 


    Select all tables in Word with VBA code
    Easily select all tables in Word with Kutools for Word


    Select all tables in Word with VBA code

    1. Press Alt + F11 keys to open the Microsoft Visual Basic for Application window.

    2. In the opening Microsoft Visual Basic for Applications window, click Insert > Module, Then copy and paste the following VBA code into the Module window;

    VBA code: Select all tables in current document:

    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. Press the F5 key to run the code

    Then all tables are selected in current document immediately.


    Easily select all tables in Word with Kutools for Word

    Comparing with using a VBA code to select all tables in a document, Kutools for Word’s Select Tables utility is quite handy. You can use this feature to select tables in a selection or the whole document. Please do as follows:

    Kutools for Word : With more than 100 handy Word add-ins, free to try with no limitation in 60 days.

    Click Kutools > Tables > Select Tables. See screenshot:

    Note: For selecting tables in selection, you need to select the range firstly and then apply the feature.

    Then you can see the results as follows.

    Select tables in selection:

    Select tables in the whole document:

    If you want to have a free trial of this utility, please go to free download the software first, and then go to apply the operation according above steps.


    Demo: Easily select all tables in Word with Kutools for Word



    Recommended Word Productivity Tools

    shot kutools word kutools tab 1180x121

    shot kutools word kutools plus tab 1180x120

    Kutools For Word — More Than 100 Advanced Features For Word, Save Your 50% Time

    • Complicated and repeated operations can be done one-time processing in seconds.
    • Insert multiple images across folders into Word document at once.
    • Merge and combine multiple Word files across folders into one with your desired order.
    • Split the current document into separate documents according to heading, section break or other criteria.
    • Convert files between Doc and Docx, Docx and PDF, collection of tools for common conversions and selection, and so on…

    Comments (10)


    No ratings yet. Be the first to rate!

    Asked
    11 years, 4 months ago

    Viewed
    2k times

    I have a Word document with captions on tables, and the tables have cheat sheet values. How to create a macro that detects all tables (ActiveDocument.GetCrossReferenceItems(Referencetype:="Table")), and transfer the tables into a new document?
    The MS Word documencation nor the autocomplete were helping.

    asked Dec 3, 2011 at 3:46

    Ming-Tang's user avatar

    This procedure copies all tables from the active document and pastes into a new document:

    Sub CopyAllTablesToNewDoc()
    
        Dim docSource As Document
        Dim docDest As Document
        Dim tbl As Table
    
        Set docSource = ActiveDocument
        Set docDest = Documents.Add
    
        For Each tbl In docSource.Tables
            tbl.Range.Copy
            docDest.Paragraphs(docDest.Paragraphs.Count).Range.Paste
            docDest.Range.InsertParagraphAfter
        Next tbl
    
    End Sub
    

    Note: it does not copy the table captions.

    answered Dec 3, 2011 at 7:29

    Rachel Hettinger's user avatar

    Rachel HettingerRachel Hettinger

    7,8322 gold badges22 silver badges31 bronze badges

    I’m going to tell you a secret. docx files are essentially renamed zip files with some xml mixed in to handle asset placement.

    http://msdn.microsoft.com/en-us/library/aa982683%28v=office.12%29.aspx

    I’ve never tried to handle it myself, but with enough poking around with zip and xml you should find what you need.

    answered Dec 3, 2011 at 3:59

    Andrew T.'s user avatar

    Andrew T.Andrew T.

    2,0781 gold badge20 silver badges42 bronze badges

    • Remove From My Forums
    • Question

    • Hi-

      I’m trying to process some large MS Word documents and I have a question. My MS Word documents have a bunch of tables in them, separated by various lines of text. I need to find all of the tables that have a specific word in them, and convert these tables
      to text. The other tables in the document (that do not contain the specified text) need to be deleted. I was trying to use the Selection.Find.Text when true in an «IF» statement, but the code doesn’t seem to behave like I want.

      Here is my code:

      Sub Delete_Tables_Auto()


      ‘ Macro to select tables in word document one at a time, searches for text,
      ‘ if string is found, converts table. If string is not found, table is deleted

      Application.ScreenUpdating = False
      ‘ Deletes all headers

      Dim s As Section
      For Each s In ActiveDocument.Sections
      s.Headers(wdHeaderFooterPrimary).Range.Text = «»
      s.Headers(wdHeaderFooterEvenPages).Range.Text = «»
      s.Headers(wdHeaderFooterFirstPage).Range.Text = «»
      s.Footers(wdHeaderFooterPrimary).Range.Text = «»
      s.Footers(wdHeaderFooterEvenPages).Range.Text = «»
      s.Footers(wdHeaderFooterFirstPage).Range.Text = «»
      Next s

      For Each atable In ActiveDocument.Tables
      atable.Select

      Selection.Find.ClearFormatting
      With Selection.Find
          .Forward = True
          .ClearFormatting
          .MatchWholeWord = True
          .MatchCase = False
          .Wrap = wdFindContinue
      End With

      If (Selection.Find.Text = «Document No.») Then
         atable.Rows.ConvertToText Separator:=wdSeparateByParagraphs
      Else
      MsgBox «deleting table»
      atable.Delete
      End If

      Next atable
      Application.ScreenUpdating = True
      End Sub

    Old

    07-29-2015, 05:03 AM

    majed_m
    majed_m is offline

    select all tables Windows 7 32bit select all tables Office 2007

    Novice

    select all tables

     

    Join Date: Jul 2015

    Posts: 3

    majed_m is on a distinguished road

    Default

    select all tables



    how can i select all tables using vba in word 2007

    Reply With Quote

    Old

    07-29-2015, 05:32 AM

    Default


    You can’t. Whatever you want to do to the tables would have to be done via Table Styles (assuming they share properties controlled by a common Style) or iteratively.

    __________________
    Cheers,
    Paul Edstein
    [Fmr MS MVP — Word]

    Reply With Quote

    Old

    07-29-2015, 10:16 PM

    majed_m
    majed_m is offline

    select all tables Windows 7 32bit select all tables Office 2007

    Novice

    select all tables

     

    Join Date: Jul 2015

    Posts: 3

    majed_m is on a distinguished road

    Question

    copy all table from word to excel


    i have a word decoument (tables, word, draw) i need only tables to copy them and paste them in excel file

    can this problem done by vba either from word or excel vba

    Reply With Quote

    Old

    07-29-2015, 10:32 PM

    Default


    Yes, you can do it from either Excel or Word. The most appropriate app to do it from depends on what your needs are but, if there’s more than one document at a time involved, I would usually prefer to do it from Excel.

    __________________
    Cheers,
    Paul Edstein
    [Fmr MS MVP — Word]

    Reply With Quote

    Old

    07-30-2015, 02:50 AM

    majed_m
    majed_m is offline

    select all tables Windows 7 32bit select all tables Office 2007

    Novice

    select all tables

     

    Join Date: Jul 2015

    Posts: 3

    majed_m is on a distinguished road

    Default


    how can i do it

    Reply With Quote

    Old

    07-30-2015, 03:29 AM

    Default


    Since you haven’t said what the scope of the task is (e.g. how many tables, how they’re formatted, how many documents are involved, where in the workbook the tables are to go, or anything else relevant), no one can tell you that. We’re not mind-readers and you really haven’t given any details…

    __________________
    Cheers,
    Paul Edstein
    [Fmr MS MVP — Word]

    Reply With Quote

    Like this post? Please share to your friends:
  • Word find all references
  • Word find all numbers
  • Word find all links
  • Word find all highlighted text
  • Word find all fonts