Word Macro Of The Day: Nuke’m Tables!

Convert all tables to text macroToday’s kudos go to Jaros_aw Michalak at www.proz.com for a stroke-of-genius-kind-solution to a problem I have been recently facing.

I had to deal with a word file of about 30 pages full of tables big and small, formatted from innocently poor to viciously abhorrent. After a couple of minutes it became painfully apparent that the tables actually made no sense and the presented dataset could be boiled down to a bulleted list. So here we go:

Given: A bunch of tables that make no sense.

Required: Convert all tables to text in a flash.

Solution: A macro with just five lines from Jaros_aw Michalak that goes like this:

Sub AllTablestoText()
For Each aTable In ActiveDocument.Tables
aTable.ConvertToText wdSeparateByCommas, True
Next aTable
End Sub

Copy this baby into a macros module (here’s how) of your file, or default template, and off you go to convert all tables to text in your entire document.

The conversion happens instantly, and as you can see from the code, this macro uses commas (wdSeparateByCommas) as columns separators in the resulting text. If you paragraph, or tabs-kind-of-guy/girl, use wdSeparateByParagraphs or wdSeparateByTabs respecively.

If the presented dataset does not warrant table use, nuk’e em tables with this awesome macro!



				
				

Dmitry Shesterin

Dmitry has done everything. From sales and marketing in mobile telecommunications and printing (in Russia and Germany) to sales engineer and marketing lead (at Faronics). Dmitry has an unrivaled love of Excel and his sense of humor resembles Ambrose Bierce, his favorite writer.