View Single Post
  #2   Report Post  
Jay Freedman
 
Posts: n/a
Default

lebur05 wrote:
I am using a program that generates a MSWord doc. The tables
generated in the docs have columns that a different widths.

Is there a way to set the column widths for all the tables to one
standard width without having to manually change each table?

Thanks


If you want all the columns to be the same widths across each table (so in a
3-column table each column is 1/3 the page width, in a 4-column table each
is 1/4 the page width, and so on), use this macro (see
http://www.gmayor.com/installing_macro.htm if necessary):

Sub AllTablesUniformCols()
Dim oTbl As Table

For Each oTbl In ActiveDocument.Tables
oTbl.Columns.DistributeWidth
Next oTbl
End Sub

If all the tables have the same number of columns, but they need to be of
different widths, you can do something like this instead (adjust as
necessary):

Sub AllTablesSetWidths()
' assumes every table has 3 columns
Dim oTbl As Table

For Each oTbl In ActiveDocument.Tables
oTbl.Columns(1).Width = InchesToPoints(1.5)
oTbl.Columns(2).Width = InchesToPoints(2.5)
oTbl.Columns(3).Width = InchesToPoints(1.7)
Next oTbl
End Sub

If neither of these is suitable, describe your tables in more detail, and we
can probably work something out.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org