楼主 0Mouse |
Q:如何批量取消边框线代之以自定义磅值的线条呢? A:代码如下:- Sub 批量取消边框线代之以自定义磅值的线条()
- Dim rg As Range, wgt As Double, rng As Range
- Set rng = ActiveCell
- wgt = 0.8 '线条宽度
- For Each rg In ActiveSheet.UsedRange
- If rg.Borders(xlEdgeBottom).LineStyle <> xlNone Then '下边框线
- rg.Borders(xlEdgeBottom).LineStyle = xlNone
- ActiveSheet.Shapes.AddConnector(msoConnectorStraight, rg.Left, rg.Offset(1).Top, rg.Offset(, 1).Left, rg.Offset(1).Top).Select
- With Selection.ShapeRange.Line
- .ForeColor.RGB = RGB(0, 0, 0) '颜色黑色
- .Weight = wgt '线条宽度
- End With
- End If
- If rg.Borders(xlEdgeTop).LineStyle <> xlNone Then '上边框线
- rg.Borders(xlEdgeTop).LineStyle = xlNone
- ActiveSheet.Shapes.AddConnector(msoConnectorStraight, rg.Left, rg.Top, rg.Offset(, 1).Left, rg.Top).Select
- With Selection.ShapeRange.Line
- .ForeColor.RGB = RGB(0, 0, 0)
- .Weight = wgt
- End With
- End If
- If rg.Borders(xlEdgeLeft).LineStyle <> xlNone Then '左边框线
- rg.Borders(xlEdgeLeft).LineStyle = xlNone
- ActiveSheet.Shapes.AddConnector(msoConnectorStraight, rg.Left, rg.Top, rg.Left, rg.Offset(1).Top).Select
- With Selection.ShapeRange.Line
- .ForeColor.RGB = RGB(0, 0, 0)
- .Weight = wgt
- End With
- End If
- If rg.Borders(xlEdgeRight).LineStyle <> xlNone Then '右边框线
- rg.Borders(xlEdgeRight).LineStyle = xlNone
- ActiveSheet.Shapes.AddConnector(msoConnectorStraight, rg.Offset(, 1).Left, rg.Top, rg.Offset(, 1).Left, rg.Offset(1).Top).Select
- With Selection.ShapeRange.Line
- .ForeColor.RGB = RGB(0, 0, 0)
- .Weight = wgt
- End With
- End If
- Next
- rng.Select
- End Sub
附件: 批量取消边框线代之以自定义磅值的线条.rar |