You can convert a table manually, but if your document has a lot of them, the manual process is tedious. Word complicates the process, because you can't select all of the tables at once the way you can other components. You can use Word's built-in selection tools to quickly select the tables one at a time (avoiding scrolling oblivion), but you'll still have to convert each one manually. In this article, I'll show you three ways to manually cycle through all the tables so you can convert them (or apply some other format change). Then, I'll show you a macro that converts all the tables for you.
Even if you don't need to convert tables, you may still learn some useful selection methods here. In addition, the macro can be easily adjusted to cycle through the Tables collection for reasons other than conversion. You can work with any Word document that contains a few tables, or you can download the sample .docm or .doc file. You can enter the macro yourself (it's short), or download the .cls module file.
The first manual selection method I want to show you is Word's Go To feature — [F5]:
- Press [F5].
- In the resulting Find And Replace dialog, choose Table from the Go To What list.
- Click Previous or Next, and Word will select a table accordingly (Figure A).
- To convert the selected table, click the contextual Layout tab, and then click Convert To Text in the Data group (the Find And Replace dialog will remain open). In Word 2003, choose Convert from the Table menu, and then select Table To Text.
- Select the appropriate separator (paragraph mark, tab, and so on) and click OK.
- Repeat steps 3 through 5 until you're done.
- Click Close to return to the document.
This method is easy, but the dialog can obstruct your view of the document, which might be a problem. If so, use the Select Browse Object. This button is at the bottom right corner of your screen, just below the vertical scroll bar. There's a small round dot with arrows just above and below. You might find this method of jumping from table to table a bit easier:
- Click the Select Browse Object button to display a palette of objects.
- From the palette, choose Browse by Table (Figure B).
- Click Previous or Next (the up and down arrows above and below the button, respectively).
- When Word selects the table, repeat steps 4 and 5 above.
- Continue until you're done.
The last method I want to show you, the Find feature, is probably familiar to you (but isn't supported by Word 2003):
- On the Home tab, click Find in the Editing group, and Word will open the Navigation pane.
- Choose Tables from the Find Options drop-down menu (Figure C).
- Repeat steps 4 and 5 from the Go To method to convert the selected table.
- To select the next table, click the Next Search Result button in the Navigation pane (Figure D).
- Continue until you're done.
The cycling macro
All three methods eliminate the messy business of scrolling through all the text between each table, but you still have to manually convert each table. Keep in mind that you can use all three of these techniques to find other objects. Now, let's look at the macro that converts all of the tables with a click:
Sub ConvertAllTablesToText() 'Convert all the tables in current document to text. Dim tbl As Table For Each tbl In ActiveDocument.Tables tbl.ConvertToText Separator:=wdSeparateByTabs Next End Sub
To use this macro, you'll need to enter it into the document's ThisDocument module as follows:
- With the document open, press [Alt]+[F11] to open the Visual Basic Editor.
- Open the document's ThisDocument module using the VBE Project Explorer (to the left). If it isn't open, press [Ctrl]+[R] or choose Project Explorer from the View menu.
- Enter the macro (don't copy and paste from this web page; you must type it or download the .cls file).
- To run the macro, return to the document, and click the Developer tab.
- Click Macros in the Code group.
- In the resulting dialog, identify the macro (Figure E).
- Click Run.
The macro cycles through all of the tables in the Tables collection and executes the ConvertToText method against each. I used the tab separator, but you can change this constant to suit your tables:
You can replace the convert statement in the For loop and use this macro to make formatting, style, or property changes to all of the tables in the same document. In addition, the selection methods I've highlighted here can be used in numerous situations.
Send me your question about Office
I answer readers' questions when I can, but there's no guarantee. When contacting me, be as specific as possible. For instance, "Please troubleshoot my workbook and fix what's wrong" probably won't get a response, but "Can you tell me why this formula isn't returning the expected results?" might. I'm not reimbursed by TechRepublic for my time or expertise, nor do I ask for a fee from readers. You can contact me at email@example.com.
Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.