老大不在,小弟糊弄顶一下.
Sub Example()
Dim oTable As Table, oCell As Cell, i As Byte
On Error Resume Next '忽略错误
Application.ScreenUpdating = False '关闭屏幕更新
With ActiveDocument
For Each oTable In .Tables '在文档的表格间循环
For Each oCell In oTable.Range.Cells '在表格的单元格间循环
With oCell
If Len(.Range) > 2 Then '如果有文字(没有的话就=2,注意不是1)
.Shading.BackgroundPatternColor = wdColorGray20 '底纹20%的灰度
For i = 1 To 4 '在单元格的上下左右,四个边循环.我们通常用形如这样的wdBorderRight等表示四边,无疑老大比我们走得更远,更高,更强.
With .Borders(-i)
.LineStyle = wdLineStyleSingle '单线条
.LineWidth = wdLineWidth150pt '宽度1.5磅
End With
Next
End If
End With
Next
Next
End With
Application.ScreenUpdating = True '开启屏幕更新
End Sub
'----------------------------------------
另:用这个
For Each borderLoop In .Borders
.......
Next borderLoop
好像可以在边框边上加对角线上循环.
[此贴子已经被作者于2005-10-6 12:27:44编辑过] |