要用vba在工作表中添加直线,可以使用Shapes对象的AddLine方法。
以下代码举例说明了用AddLine方法添加直线:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Sub QQ1722187970() Dim oSP As Shape Dim oWK As Worksheet Set oWK = Excel.ActiveSheet '先删除存在的直线 For Each oSP In oWK.Shapes With oSP If .Type = msoLine Then .Delete End If End With Next '添加直线 Set oSP = oWK.Shapes.AddLine(0, 0, 100, 100) With oSP Debug.Print .Name End With End Sub |
除了[……]
阅读全文>>>