已实现,对选中形状进行自动编号,前台传入前缀编号NoText
Private Sub NumberButton_Click()
'MsgBox Me.NoText.Value ActiveSelectionRange.Count
NoText = UserForm1.NoText.Value
Dim s As Shape
Dim i As Integer
i = 1
' 遍历选中的形状
For Each s In ActiveSelectionRange
' 获取形状的中心坐标
Dim centerX As Double
Dim centerY As Double
centerX = s.centerX
centerY = s.centerY
' 创建艺术字形状,并设置文本内容为数字
Dim textShape As Shape
Set textShape = ActiveLayer.CreateArtisticText(centerX, centerY, NoText & i, cdrAmericanEnglish, cdrCharSetDefault, "NSimSun", s.OriginalHeight * 2, cdrTrue)
'NSimSun为字体 s.centerY * 2
'12为字号
textShape.centerX = s.centerX
textShape.centerY = s.centerY
i = i + 1
Next s
End Sub