可能我理解错了! 再请参: '* +++++++++++++++++++++++++++++
'* Created By I Love You_Word!@ExcelHome 2005-3-17 5:52:36
'仅测试于System: Windows NT Word: 10.0 Language: 2052
'^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------Option Explicit
Sub Example()
Dim i As Cell, CellStartRange As Range, CellEndRange As Range
Dim StartLine As Integer, EndLine As Integer
On Error Resume Next '忽略错误
With ActiveDocument.Tables(1) '活动文档表格1
For Each i In .Range.Cells '在表格1单元格中循环
With i.Range '单元格区域
If .End - .Start = 1 Then GoTo GONE '没有文本则进入GONE行标签语句
'单元格起始区域为第一个文字
Set CellStartRange = ActiveDocument.Range(.Start, .Start + 1)
'单元格结束区域为最后一个文字(注意是文字)
Set CellEndRange = ActiveDocument.Range(.End - 2, .End - 1)
End With
'获得指定文字区域的行号
StartLine = CellStartRange.Information(wdFirstCharacterLineNumber)
EndLine = CellEndRange.Information(wdFirstCharacterLineNumber)
If EndLine <> StartLine Then '对话框提示
MsgBox "单元格(" & i.RowIndex & "," & i.ColumnIndex _
& ")中有" & EndLine - StartLine + 1 & "行内容"
Else
GONE: MsgBox "单元格(" & i.RowIndex & "," & i.ColumnIndex & ")中没有换行"
End If
Next
End With
End Sub
'---------------------- |