I had a document that had 20+ tables in it that were all identical in format. I wanted to make one large table, so I deleted the heading rows and material between and got one large table. The problem was that the column sizes changed during the joins so that there were portions where column two might be 120 points, followed by 118 points, followed by, well you get the idea. This made it so that you could not select a column and resize it and have it propagate all the way down.
My first idea was to type in the VBA window something like
For n = 1 to Activedocument.Tables(1).Rows.Count: For m = 1 to Activedocument.Tables(1).Columns.Count:Activedocument.Tables(1).Cell(n,m).Width=120:Next:Next
It worked. Sort of. Microsoft in their infinite wisdom has PREFERRED widths for cells, not absolute widths. The end result was that most of the cells were the proper 120 width, but enough were slightly off so as to make it worse than at the beginning. I finally had to create a new table to receive the data from the original and then do a lot of looping through the cells in VBA to copy the shading, etc.
I have had aggravations with Preferred Widths before. Does anyone know an easy way to force columns to line up when joining tables?
Joining tables
-
- Administrator
- Posts: 78530
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Joining tables
Did you set the AllowAutoFit property of the table to False?
And did you set the PreferredWidthType for the table/columns/cells to wdPreferredWidthPoints?
And did you set the PreferredWidthType for the table/columns/cells to wdPreferredWidthPoints?
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 29
- Joined: 09 Feb 2010, 01:39
- Location: Colorado, USA
Re: Joining tables
That was the missing piece. Thanks Hans!