I want to iterate through each table in a document and make som column
adjustments, see code below.
However, in order to make this work, I guess I need to select left cell in
first row in the table before performing a table column title search and the
column adjustment.
How do I select the left cell in first row in the table?
Regards
Frank Krogh
Sub AdjustTables()
Application.ScreenUpdating = False
For Each aTable In ActiveDocument.Tables
aTable.AutoFitBehavior (wdAutoFitContent)
FixTablesColumns
Next aTable
Application.ScreenUpdating = True
End Sub
Sub FixTablesColumns()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "given table column title"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(2.24)
Selection.Find.ClearFormatting
Selection.MoveLeft Unit:=wdCharacter, Count:=1
' other table column adjustments here ...
end sub
Jezebel - 19 Oct 2006 11:08 GMT
Dim pCell as Word.Cell
set pCell = aTable.Cells(1,1)
>I want to iterate through each table in a document and make som column
> adjustments, see code below.
[quoted text clipped - 43 lines]
>
> end sub
Frank - 19 Oct 2006 12:33 GMT
Thank you for the suggestion.
However, I get a run time error '438': Object doesn't support this property
or method, when I try this code:
Dim pCell As Word.Cell
Application.ScreenUpdating = False
For Each aTable In ActiveDocument.Tables
aTable.AutoFitBehavior (wdAutoFitContent)
Set pCell = aTable.Cells(1, 1)
FixTableColumns
Next aTable
Application.ScreenUpdating = True
> Dim pCell as Word.Cell
>
[quoted text clipped - 47 lines]
> >
> > end sub
Tony Jollans - 19 Oct 2006 12:42 GMT
Use Cell instead of Cell*s*.
--
Enjoy,
Tony
> Thank you for the suggestion.
>
[quoted text clipped - 62 lines]
> > >
> > > end sub