Mark was telling us:
Mark nous racontait que :
Jean-Guy,
Thank you very much, you have been most helpful yet again!
Well, I could have been more helpful...
I should have thought of the information property, which works even with
merged cells. So using Jay's suggestion and my previous code, here is a
revised version that will work regardless of cell merging:
Dim CellCoordinate As String
Dim CurRange As Range
If Not Selection.Information(wdWithInTable) Then
MsgBox "You must select a cell in a table.", vbCritical, "Error"
Else
Set CurRange = Selection.Range
'In case users selects more than one cell
Selection.Collapse wdCollapseStart
CellCoordinate = CStr(ActiveDocument.Range(0,
CurRange.Start).Tables.Count)
With Selection
CellCoordinate = CellCoordinate _
& CStr(.Information(wdStartOfRangeColumnNumber))
CellCoordinate = CellCoordinate _
& CStr(.Information(wdStartOfRangeRowNumber))
End With
Selection.Range.InsertAfter CellCoordinate
CurRange.Select
End If
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org