Site icon 承銷人忙什麼

【WORD VBA】表格加邊框線條加黑網底變白

Sub 表格加邊框線條加黑網底變白()

Dim borderLoop As Border

Dim i, s As Integer

i = ActiveDocument.Tables.Count

For s = 1 To i

If ActiveDocument.Tables.Count >= 1 Then
For Each borderLoop In ActiveDocument.Tables(s).Borders
With borderLoop
.ColorIndex = wdBlack ‘將框線設定為黑色。
.LineStyle = wdLineStyleNone ‘消除原有框線設定。
End With
Next borderLoop
End If

Next s

For s = 1 To i

If ActiveDocument.Tables.Count >= 1 Then
Set mytable = ActiveDocument.Tables(s)
mytable.Borders.OutsideLineStyle = wdLineStyleSingle
mytable.Borders.OutsideLineWidth = wdLineWidth150pt ‘將外部框線設定為1.50pt。
mytable.Borders.InsideLineStyle = wdLineStyleSingle
mytable.Borders.InsideLineWidth = wdLineWidth075pt ‘將內部框線設定為0.75pt。
mytable.Shading.BackgroundPatternColor = wdColorWhite ‘將表格網底設定為白色。
End If

Next s

End Sub

Exit mobile version