|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Macro to change each individual cell to 0 padding, one at a time in a table with merged cells.
Hi.
I have scoured the net for days now, and even though I've found a couple of macros that work when the table has no merged cells, or does the whole document, I haven't found a macro that will check each cell in a table and change it's margins/padding. I've discovered that for Word, each individual cell in the table has it's own margins, which overrule any changes to the table as a whole. The only way I can remove all white space from within a table, is to click on each cell and change it's margins to 0, or tick the box that says "same as whole table". Selecting the whole table and changing these numbers does diddly-squat to the individual cells. I've done a simple macro that I can run manually for each cell, but I am converting documents that have anything from 200 pages to 700 pages of tables. The tables are specialized in this business (Aviation), so they MUST remain exactly as they already are when it comes to shape, borders and size. I will control the space around the text using paragraph formatting. I can sort of decipher and "read" macro's, but am not that familiar with VBA, so would really appreciate if someone could please write me a VBA that will check each cell within a selected table, regardless if merged, and change the margin/padding to 0. Thanks. |
#2
|
||||
|
||||
How about
Code:
Sub Macro1() Dim oCell As Cell Dim oTable As Table Set oTable = Selection.Tables(1) For Each oCell In oTable.Range.Cells With oCell .TopPadding = InchesToPoints(0) .BottomPadding = InchesToPoints(0) .LeftPadding = InchesToPoints(0) .RightPadding = InchesToPoints(0) End With Next oCell End Sub Code:
Sub Macro2() Dim oCell As Cell Dim oTable As Table For Each oTable In ActiveDocument.Tables For Each oCell In oTable.Range.Cells With oCell .TopPadding = InchesToPoints(0) .BottomPadding = InchesToPoints(0) .LeftPadding = InchesToPoints(0) .RightPadding = InchesToPoints(0) End With Next oCell DoEvents Next oTable End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Thankyou!!
You awesome person!! Thank you! The single one worked awesomely. I'll try the other one, but even just the first one is fantastic.
I need to learn how to write VBA.. LOL Quote:
|
#4
|
||||
|
||||
There is no point in this conversion, using just
Code:
... = 0
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Table Row with merged cells | andi_bln | Word VBA | 3 | 10-15-2020 01:22 AM |
How to get autonumber series if adjacent cell has merged cells? | kingston123 | Excel | 3 | 06-28-2020 09:12 AM |
Converting table to text (and back) with carriage returns in cells, split and merged cells | ndajko | Word | 5 | 11-04-2019 07:53 AM |
Merging 2 different cells containing IF formula & change in cell values based on multiple time frame | jay_excel | Excel | 0 | 07-29-2017 11:04 PM |
Table will not allow sorting because "cells are merged". I can't find the merged cells. | wendyloooo | Word Tables | 1 | 05-26-2015 01:19 PM |