#1
|
|||
|
|||
Problem with Cell Margins
Hello everyone,
I work as an editor for an audit firm. From time to time, I get reports with tables that have a problem that I hope you can help me solve. I am sure it has to do with Cell Margins settings but no matter what I do with them, it doesn't seem to fix the issue completely. I use decimal tabs to align numbers in tables. I just select all the columns in a table, put a decimal tab and all the numbers get aligned nice and fast. The problem with some tables is that different cells within a single table have different cell margins. So I have to go to these cells and adjust the position of the decimal tab to make the number properly aligned and, apart from being very annoying, it can also take a long time, especially if a table is very long and full of such glitches. I tried selecting the table and going to "Table Tools" - "Layout" - "Cell Margins" and setting Left and Right Margins to some number, hoping it would have an effect on all the cells and make their margins equal. But no, they still retain their "glitchy" margins I attached a document that has a problem table so you can see what I mean and maybe find a way of fixing it. Note that cells in "Accumulated deficit" column have different margins. (And numbers are not aligned properly) How can I make the cell margins equal in the entire table??? Thank you all for your help. |
#2
|
||||
|
||||
Hi Aston,
Although the various 'currency' cells in your table have a "Table numbers1" Style attached to them, it look like someone has been manually overriding that. Some of the 'currency' cells also have a different top/bottom padding than other 'currency' cells and the table defaults. It's these two things together that seem to be messing up the formatting. The following macro goes through all the cells with the "Table numbers1" Style attached, in all tables in the document, and re-formats them with the "Table numbers1" Style correctly applied and the cell padding the same as the table generally: Code:
Sub FixTables() Dim Tbl As Table, oCel As Cell, Rng As Range, bBld As Boolean With ActiveDocument For Each Tbl In .Tables For Each oCel In Tbl.Range.Cells With oCel If .Range.Style = "Table numbers1" Then bBld = .Range.Font.Bold .TopPadding = Tbl.TopPadding .BottomPadding = Tbl.BottomPadding .RightPadding = Tbl.RightPadding .LeftPadding = Tbl.LeftPadding .Range.Style = "Table numbers1" .Range.Font.Bold = bBld End If End With Next Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Macropod,
let me express my greatest appreciation for your help. You are truly a terrific expert. I applied your macro and it's done wonders. Now I'm going to spend some time to understand what this macro is actually doing, because I'm not sure I have a full understanding of what's really going on. Thank you. Last edited by Aston; 05-08-2011 at 05:49 AM. Reason: Update |
#4
|
||||
|
||||
Quote:
I'm glad to hear you're interested enough to want to study the code - that's a good way to build up your own skills.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
I just realized that this "Cell Margins" button on Table Tools' Layout tab always shows (default?) margins for the entire table and not for a specific cell. Looking at the ruler, it is visually noticeable that the margins in different cells are different, but when I place the cursor in these cells and click this button, it always shows the same values regardless of what the ruler shows.
I found out that if you want to see the actual margins for a specific cell, you have to right-click the cell, go to "Table Properties" - "Cell Tab" - click on the "Options" button and here it is, a deeply-buried-but-so-much-needed-in-my-case dialog box called Cell Options (or is there a shortcut???). Here you can adjust cell margins as needed or just check "Same as the whole table" box. And the problem is solved. Thank you once again, macropod |
#6
|
||||
|
||||
Hi Aston,
Yes, it only shows the table defaults, not the settings for the current cell. And, while there's an option for each cell that you can get to and click to re-set it, that doesn't seem to work for more than one cell at a time and isn't exposed to vba. Hence the need to reset all the values individually, and on a cell-by cell basis. The keyboard access to the dialogue box is Alt-a, r, e, Alt-o. Not exactly a shortcut, but there it is.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Problem with Cell Margins
Paul Edstein aka Macropod:
Thank you ever so much for the code posted re cell padding. Our project is now required to have a specific cell padding for tables, but I have had many problems with getting it to apply properly -- and stay -- when selecting the entire table and applying the padding. (We also have numerous documents with numerous table, so this new requirement adds much time and effort.) I modified your code to include Allow row to break across pages = False and to do the cell padding. It is like magic -- and an answer to the prayers of the three editors on the project. Thanks again. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inconsistent Margins | judyfogarty | Word | 0 | 08-01-2010 02:54 AM |
How can I fill cell color starting from Cell D5 using Conditional formatting instead | Learner7 | Excel | 0 | 07-08-2010 05:50 AM |
How can I make a cell color RED under the Today's date cell? | Learner7 | Excel | 2 | 07-08-2010 12:52 AM |
Margins | xGAME-OVERx | Word | 8 | 10-24-2009 06:39 AM |
Auto-populate an MS Word table cell with text from a diff cell? | dreamrthts | Word Tables | 0 | 03-20-2009 01:49 PM |