View Single Post
  #2   Report Post  
Posted to microsoft.public.word.tables
Jay Freedman
 
Posts: n/a
Default Macro to find specific tables

Hi Mike,

You don't have to "find" the tables. You just run a For Each loop over
all the tables, and modify only the ones that have four columns. This
should do it:

Sub ResizeTables()
Dim oTbl As Table

For Each oTbl In ActiveDocument.Tables
With oTbl
If .Columns.Count = 4 Then
.AutoFitBehavior Behavior:=wdAutoFitFixed
.Columns.PreferredWidthType = wdPreferredWidthPoints
.Columns.PreferredWidth = InchesToPoints(3.67)
End If
End With
Next oTbl
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Mon, 13 Mar 2006 14:35:01 -0800, MichaelB
wrote:

I am trying to figure out how to create a Macro that would find specific
tables within a document. I have several tables within some rather large
document that need to be modified to a new format. I need to identify how to
create a search for all the tables (several hundred) within the document
which have four(4) columns only. Once these tables are found I need to alter
the width of the columns to 3.67” without affecting any font styling that
currently exist.

If someone could help me out with the search criteria I'm sure I can put the
rest together.

Any help would be greatly appreciated.
Thanks
Mike