Hi =?Utf-8?B?VG9ueSBMb2dhbg==?=,
I want the user to be able to select a row (always a single row) in a table and have a macro perform "Action A" to the first cell (align contents left/bottom, for example), then "Action B" (align contents center/bottom, for example) to the remaining cells.
I'm not sure how to write the code that would identify the first cell as cell 1, second cell as cell 2, etc.
Something like this? (Note, the following allows for cells merged vertically)
Sub DoCellsInRow()
Dim iRowIndex As Long, iColIndex As Long
Dim tbl As Word.Table, iCellCounter As Long
'Handles merged cells
If Selection.Information(wdWithInTable) Then
Set tbl = Selection.Tables(1)
iRowIndex = Selection.Information(wdStartOfRangeRowNumber)
iColIndex = tbl.Columns.Count
For iCellCounter = 1 To iColIndex
If iCellCounter = 1 Then
tbl.Cell(iRowIndex, iCellCounter).Range.Text = _
"First"
Else
On Error Resume Next
tbl.Cell(iRowIndex, iCellCounter).Range.Text = _
"Col " & iCellCounter
On Error GoTo 0
End If
Next
End If
End Sub
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail