|
楼主 |
发表于 2020-4-28 13:07
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
做成完整文件,请老师指正- Sub test()
- '添加文本框
- For i = 1 To 12
- Set shp = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 20, 20, 20, 20)
- With shp
-
- End With
- With shp.TextFrame.Characters
- .Text = i
- .Font.Size = 12
- .Font.FontStyle = "加粗"
- End With
- With shp
- .Left = i * 20
- .Top = 20
- .Line.Visible = msoFalse
- .Name = "文字" & i
- End With
- Next
- '添加圆
- Set shp = ActiveSheet.Shapes.AddShape(msoShapeOval, 210, 100, 147#, 147#)
- With shp
- .Fill.ForeColor.SchemeColor = 10
- .Line.Visible = msoFalse
- End With
- With shp
- .Name = "Oval 1"
- End With
- End Sub
- Sub 图形排位()
- 'Write By:Micro,QQ:79833378
- Dim dicNum As Object, oShape As Object
- Dim nR As Double, nPointX As Double, nPointY As Double
- Dim nI As Long, nPai As Double, nX As Double, nY As Double
-
- nPai = Application.WorksheetFunction.Pi
- Set dicNum = CreateObject("Scripting.Dictionary")
- For Each oShape In ActiveSheet.Shapes
- With oShape
- If .Name Like "Text Box*" Then
- .Delete
- ElseIf .Name Like "文字*" Then
- Set dicNum(Val(Replace(oShape.Name, "文字", ""))) = oShape
- ElseIf .Name Like "Oval 1" Then
- nR = .Width / 2
- nPointX = .Left + nR
- nPointY = .Top + nR
- nR = Int(nR) + 30
- End If
- End With
- Next
- For nI = 1 To 12
- nX = nPointX + nR * Cos(nPai / 2 - nI * nPai / 6)
- nY = nPointY - nR * Sin(nPai / 2 - nI * nPai / 6)
- With dicNum(nI)
- .Left = nX - .Width / 2
- .Top = nY - .Height / 2
- End With
- Next
- End Sub
复制代码 附件:
|
|