Question

I have spent all day trying to find a solution to this issue that I thought would be simple but is proving to be very difficult.

I want to create a macro that will go through all the tables in a Word 2007 document and make sure that the left cell padding (cell margin) is set to 0 instead of the default of .08. The tables have no borders and I want the text inside the tables to be flush with the corresponding paragraphs.

I want this standard for all tables regardless of the table style. There are different tables styles in the document that are formatted in Excel and copied and pasted into the document. Since the persons performing this task sometimes forgets to manually change these cell margins until just before the printed document is going out the door, I would like to automate this step if possible.

BTW, I have seen code that supposedly works if you have the cursor in the table, but that is not what I am looking for. I want to perform this on all tables with one macro run, regardless of where the cursor is.

Many Thanks

Was it helpful?

Solution

The following code was provided to me by Greg Maxey from the Microsoft community.

Dim oTbl As Word.Table
    For Each oTbl In ActiveDocument.Tables
    oTbl.LeftPadding = 0
Next 

His Word tips webisite is at:

http://gregmaxey.mvps.org/word_tips.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top