E
Ed
This is supposed to loop through each table in the document and then loop
through all each cells in the table - if in Col 1 then make the font Arial
Narrow. But it goes to the first cell of the first table -the text there is
not 7 pt, so it should drop out of the If - and gets stuck! It won't
continue looping. What did I do wrong?
Ed
Sub TblCol_2_ANrrw()
Dim tblTemp As Table
Dim oCell As Cell
Dim rngSearch As Range
Dim inRow As Long
' Do in every table
For Each tblTemp In ActiveDocument.Tables
Set rngSearch = tblTemp.Range
For Each oCell In tblTemp.Range.Cells
' Check only column 1
If oCell.ColumnIndex = 1 Then
' Select all text in cell
inRow = rngSearch.Cells(1).RowIndex
rngSearch.Tables(1).Cell(inRow, 1).Select
Selection.Collapse Direction:=wdCollapseEnd
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.EndKey wdLine
Selection.HomeKey wdLine, wdExtend
' Replace Arial with Arial Narrow
If Selection.Font.Size = 7 Then
Selection.Font.Name = "Arial Narrow"
End If
End If
Next oCell
Next tblTemp
End Sub
through all each cells in the table - if in Col 1 then make the font Arial
Narrow. But it goes to the first cell of the first table -the text there is
not 7 pt, so it should drop out of the If - and gets stuck! It won't
continue looping. What did I do wrong?
Ed
Sub TblCol_2_ANrrw()
Dim tblTemp As Table
Dim oCell As Cell
Dim rngSearch As Range
Dim inRow As Long
' Do in every table
For Each tblTemp In ActiveDocument.Tables
Set rngSearch = tblTemp.Range
For Each oCell In tblTemp.Range.Cells
' Check only column 1
If oCell.ColumnIndex = 1 Then
' Select all text in cell
inRow = rngSearch.Cells(1).RowIndex
rngSearch.Tables(1).Cell(inRow, 1).Select
Selection.Collapse Direction:=wdCollapseEnd
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.EndKey wdLine
Selection.HomeKey wdLine, wdExtend
' Replace Arial with Arial Narrow
If Selection.Font.Size = 7 Then
Selection.Font.Name = "Arial Narrow"
End If
End If
Next oCell
Next tblTemp
End Sub