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

Jay,

Thanks for the information I truly appreciate it..! With me being new to
VBA I am trying to understand it as much as I can. Is it possible to modify
the widths of each column separately? If I wanted to make column 1 = 1,
column 2 = .69 and column 3 = .63 and column 4 = 3 how would I go about
doing so within the script you provided? I believe if I was able to see this
I would better understand the table objects (maybe not). I believe I am lucky
enough to have no merged or split cells therefore Im hoping this to be
pretty straight forward (just beyond my comprehension is all).

Can you also help me understand the script by defining what the two lines
within are doing (meaning)?

..AutoFitBehavior Behavior:=wdAutoFitFixed
..Columns.PreferredWidthType = wdPreferredWidthPoints

Again, thanks for the help, I am truly grateful.

Mike



"Jay Freedman" wrote:

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