|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
仅仅分析了那个数组问题,用公式替代,不知道效果是否好些,供楼主参考。2007或者以上版本中代码有问题。只能在doc格式文档中插入。
略改进了一个小位置:将艺术字放在圈的上面,方便对艺术字的编辑。
Sub 电子印章()
If Documents.Count = 0 Then Documents.Add
Dim i$, j&, a$, f$, x!, s, t, r, arr(1 To 4) As String
ipt:
i = InputBox("印章正文(3-30字)和附言(2-6字)可以一起输入,但必须以中文逗号,分隔!", "电子印章", "辽宁省朝阳市通用模板公司,业务专用章")
If i = "" Then Exit Sub
a = InStrRev(i, ",")
If a Then f = Mid(i, a + 1): i = Left(i, a - 1) Else f = "财务专用章"
j = Len(i)
If j < 3 Or j > 30 Or Len(f) < 2 Or Len(f) > 6 Then GoTo ipt
If Len(f) = 5 Then
x = 258.4!
ElseIf Len(f) = 4 Then x = 264.5!
ElseIf Len(f) = 3 Then x = 263.5!: f = Left(f, 1) & " " & Mid(f, 2, 1) & " " & Right(f, 1)
ElseIf Len(f) = 2 Then x = 270.5!: f = Left(f, 1) & " " & Right(f, 1)
ElseIf Len(f) = 6 Then x = 251.5!
End If
Dim B2 As Integer
' s = Array(3.9!, 3!, 2.4!, 1.98!, 1.7!, 1.48!, 1.33!, 1.19!, 1.08!, 1!, 0.92!, 0.86!, 0.8!, 0.75!, 0.7!, 0.67!, 0.63!, 0.6!, 0.57!, 0.55!, 0.52!, 0.5!, 0.48!, 0.46!, 0.45!, 0.43!, 0.41!, 0.4!)
' t = Array(5!, 5!, 4.9!, 3.9!, 3.5!, 3.1!, 2.8!, 2.5!, 2.3!, 2!, 1.8!, 1.7!, 1.6!, 1.5!, 1.4!, 1.3!, 1.32!, 1.27!, 1.2!, 1.1!, 1.1!, 1.05!, 1!, 0.97!, 0.93!, 0.88!, 0.85!, 0.8!)
' r = Array(220!, 235!, 243!, 247!, 251!, 252!, 255!, 257!, 258.5!, 260.5!, 262!, 264!, 264.5!, 265.5!, 266.5!, 267!, 268!, 269!, 269!, 269!, 269!, 269!, 269.5!, 269.5!, 269.5!, 269.5!, 269.9!, 269.9!)
With ActiveDocument.Shapes
With .AddShape(msoShapeOval, 201.6!, 85!, 180!, 180!) '圆周
.Fill.Transparency = 1!
.Line.Weight = 3.5
.Line.Style = msoLineThickThin
arr(2) = .Name
End With
' With .AddTextEffect(msoTextEffect3, i, "宋体", 12!, msoFalse, msoFalse, 219.75!, 103!) '艺术字
' .TextEffect.Tracking = t(j - 3)
' .ScaleHeight 12, msoFalse, msoScaleFromTopLeft
' .ScaleWidth s(j - 3), msoFalse, msoScaleFromTopLeft
' .Adjustments(1) = r(j - 3)
' arr(1) = .Name
' End With
B2 = j - 2
With .AddTextEffect(msoTextEffect3, i, "宋体", 12!, msoFalse, msoFalse, 219.75!, 103!) '艺术字
.TextEffect.Tracking = -1.5330927443 * Log(B2) + 5.7446883077
.ScaleHeight 12, msoFalse, msoScaleFromTopLeft
.ScaleWidth 0.000000207 * B2 ^ 6 - 0.0000210444 * B2 ^ 5 + 0.000858918 * B2 ^ 4 - 0.0180685488 * B2 ^ 3 + 0.2102186579 * B2 ^ 2 - 1.3689925448 * B2 + 5.0548985512, msoFalse, msoScaleFromTopLeft
.Adjustments(1) = 14.2583547577 * Log(B2) + 226.1179984978
arr(1) = .Name
End With
With .AddShape(msoShape5pointStar, 264!, 147.8!, 54.9!, 47.6!) '五角星
.Line.Weight = 0.25
arr(3) = .Name
End With
With .AddTextEffect(msoTextEffect3, f, "宋体", 13!, msoTrue, msoFalse, x, 206!) '附言
.TextEffect.PresetShape = msoTextEffectShapePlainText
.Fill.Visible = msoTrue
.Line.Weight = 0.25
arr(4) = .Name
End With
With .Range(Array(arr(1), arr(2), arr(3), arr(4))).Group '组合
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Line.ForeColor.RGB = RGB(255, 0, 0)
.LockAspectRatio = msoTrue
.ScaleWidth 0.6, msoFalse, msoScaleFromTopLeft
.ScaleHeight 0.6, msoFalse, msoScaleFromTopLeft
.IncrementTop 92.6!
.IncrementLeft 119.4!
.ZOrder msoSendBehindText
.Select
End With
End With
End Sub |
|