How to copy a table's column width to another table?

I have a document with many tables that all have the same structure (i.e. columns and column width).

But now I need to add an additional column too all of these.

 

I did that with the first table but adding an additional column of course resizes all other columns. So, after doing that I had to readjust all column widths anew so they look "pretty" (automatic column width calculation didn't yield a good result here).

 

But how do I apply this now to the remaining tables? I definitely don't want to have to massage each table individually!

Is there a possibility to add another column and re-adjusts all column width in one go?

Since that's probably asking too much: can I at least carry over the column widths from the first table to all the others?

Answer
Answer

You should be able to do it with VBA.

 

Provided the first table in the document is the table you added and resized columns the following should work:

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl1 As Word.Table
Dim oTbl As Word.Table
Dim lngIndex As Long, lngCols As Long
Set oTbl1 = ActiveDocument.Tables(1)
For lngIndex = 2 To ActiveDocument.Tables.Count
  Set oTbl = ActiveDocument.Tables(lngIndex)
  oTbl.Columns.Add
  For lngCols = 1 To oTbl1.Columns.Count
    oTbl.Columns(lngCols).Width = oTbl1.Columns(lngCols).Width
  Next lngCols
Next
End Sub

Greg Maxey
***
Death smiles at us all, but all a man can do is smile back.


For more help with Word visit:
http://gregmaxey.com/word_tips.html

3 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 3, 2024 Views 9,201 Applies to: