
Tips.Net > WordTips Home > Tables > Formatting an ASCII Table with Tabs
Summary: If you get a document from a coworker that has tabs used to line up tabular information, you might want to change that type of formatting to a regular table. Word provides some capabilities to do this, but you may want to use the macro presented in this tip to make the conversion even easier. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
Many people, for one reason or another, always seem to use tabs to set up simple tables rather than using the built-in table editor that Word includes. If you want to quickly convert the "tabbed table" to a real Word table, you will appreciate this tip. The macro presented here, TabToTable, assumes that each line represents a different row in the table, and that tabs represent divisions between columns.
You might wonder why you would want to use a macro to convert a tabbed table, rather than use the Convert option from the Table menu. The reason is simple: the Convert option assumes that every tab represents a column. If you have been around the block a few times, you already know that many times tabbed tables use multiple tabs between columns. Thus, the first task of the macro is to replace multiple tabs with a single tab, and then do the conversion.
Sub TabsToTable
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^t{2,}"
.Replacement.Text = "^t"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.ConvertToTable _
Separator:=wdSeparateByTabs, _
Format:=wdTableFormatNone
End Sub
When you are ready to run the macro, simply select the text you want to convert. When you run this macro, you will get the same thing you would get if you selected the Convert option from the Table menu and then chose Text to Table. This means your columns might look funky; they will definitely need to be resized. But the hard work of getting rid of all the tabs has been done for you.
Tip #1395 applies to Microsoft Word versions: 97 2000 2002 2003 2007
More Power! Expand your skills and make Word really sing! It's all possible with macros. The best resource anywhere for macros is WordTips: The Macros. Check it out today!
It doesn't matter if you are a beginner or expert, the WordTips archives are the fastest way to improved productivity. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips