
Signature
Greg Maxey/Word MVP
A Peer in Peer to Peer Support
> Jonathan,
>
[quoted text clipped - 3 lines]
> table. I have change the code as follows. I would be interested in any
> comments you have for improving it:
You don't need the i & j. Simply insert at the selection, like this:
Sub Test()
Dim iCount As Long
Dim oCell As Cell
Dim oCol As Column
Dim oTable As Table
If Selection.Information(wdWithInTable) = True Then
Set oTable = Selection.Tables(1)
Set oCol = Selection.Columns(1)
Else
MsgBox "Selection is not in a table"
Exit Sub
End If
For Each oCell In oCol.Cells
If oCell.Range.Characters.Count > 1 Then
iCount = iCount + 1
End If
Next
Selection.InsertBefore _
"Count = " & iCount & " "
End Sub
> Thanks for the assist. I would be interested in the merged cell work
> around, just for the sake of seeing how it would be done.
This requires a bit of knowledge that goes all the way back to Wordbasic and
Word 95. It isn't documented in current versions of Word. The only way to
select a column that includes merged cells (that I know of) is to use the
WordBasic.TableSelectColumn command to select the column, and then iterate
through the cells of the Selection.
Be aware that a horizontally merged cell will register in all the columns it
has been merged from.
Sub Test()
Dim iCount As Long
Dim oCell As Cell
Dim oRange As Range
Set oRange = Selection.Range
If Selection.Information(wdWithInTable) = True Then
WordBasic.TableSelectColumn
Else
MsgBox "Selection is not in a table"
Exit Sub
End If
For Each oCell In Selection.Cells
If oCell.Range.Characters.Count > 1 Then
iCount = iCount + 1
End If
Next
oRange.Select
Selection.InsertBefore _
"Count = " & iCount & " "
End Sub

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Greg Maxey - 12 Dec 2004 00:31 GMT
Jonathan,
Thanks. I should have know that about the selection. Earlier on I was
trying to achieve the cell check by actually moving the selection through
each cell in the column and needed i and j to get back to where the IP
started. Now I see why I don't need them as the IP never moves.

Signature
Greg Maxey/Word MVP
A Peer in Peer to Peer Support
>> Jonathan,
>>
[quoted text clipped - 59 lines]
> "Count = " & iCount & " "
> End Sub