Sub GetNumberOfColumnsInCurrentRow()
Dim tbl As Table
Dim currentRow As Row
Dim numCols As Integer
' Check if the selection is in a table
If Selection.Information(wdWithInTable) Then
Set tbl = Selection.Tables(1)
Set currentRow = Selection.Rows(1)
numCols = currentRow.Cells.Count
MsgBox "Number of columns in the current row: " & numCols
Else
MsgBox "The selection is not inside a table."
End If
End Sub