Sub 表格序号填充() '对于首列为序号列的表格进行遍历填充 Dim RowC AsInteger ForEach tempTable In ActiveDocument.Tables With tempTable RowC = tempTable.Rows.Count .Cell(1, 1).Select If InStr(Selection.Text, "序号") <> 0Then For i = 2To RowC .Cell(i, 1).Select '手动编号1检测 CK1 = Selection.Range.ListFormat.ListString = "" '自动编号1检测 CK2 = Selection.Text = (Chr(13) & Chr(7)) If CK1 And CK2 Then Selection.Text = i - 1 EndIf Next EndIf EndWith Next tempTable EndSub
全部表空白格填充
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Sub 全部表空白格填充() Dim CK1, CK2 AsBoolean Dim aCell As Cell ForEach tempTable In ActiveDocument.Tables With tempTable ForEach aCell In .Range.Cells aCell.Select CK1 = (Selection.Range.ListFormat.ListString = "") CK2 = (Selection.Text = (Chr(13) & Chr(7))) If CK1 And CK2 Then Selection.Text = "-" EndIf Next aCell EndWith Next tempTable EndSub