|
本帖最后由 loquat 于 2015-8-2 22:51 编辑
按楼主的思路,将6句中的5句颜色设置精简为1句
不过估计这个修改有可能会在某些情况下出现BUG- Sub 电子印章_v5.12_loquat()
- Application.ScreenUpdating = False
- Dim i As String, s As Single, t As Single, r As Single, aLength&
- Dim arr(1 To 4) As String
- i = InputBox("请输入印章正文!(有效汉字位数:3-30)", "电子印章", "辽宁省朝阳市通用模板公司")
- If i = "" Then Exit Sub
- aLength = Len(i)
- Application.Options.AutoCreateNewDrawings = False
- If aLength = 30 Then '使用If语句替代Select语句,理论上效率会高一点点
- s = 0.4: t = 0.8: r = 269.9 '根据经验设定Tracing, ScaleWidth, Adjustments的值
- ElseIf aLength = 29 Then s = 0.41: t = 0.85: r = 269.9
- ElseIf aLength = 28 Then s = 0.43: t = 0.9: r = 269.5
- ElseIf aLength = 27 Then s = 0.45: t = 1: r = 269.5
- ElseIf aLength = 26 Then s = 0.46: t = 1: r = 269.5
- ElseIf aLength = 25 Then s = 0.48: t = 1: r = 269.5
- ElseIf aLength = 24 Then s = 0.5: t = 1.1: r = 269
- ElseIf aLength = 23 Then s = 0.52: t = 1.1: r = 269
- ElseIf aLength = 22 Then s = 0.55: t = 1.1: r = 269
- ElseIf aLength = 21 Then s = 0.57: t = 1: r = 269
- ElseIf aLength = 20 Then s = 0.6: t = 1.1: r = 269
- ElseIf aLength = 19 Then s = 0.63: t = 1.2: r = 268
- ElseIf aLength = 18 Then s = 0.67: t = 1.3: r = 267
- ElseIf aLength = 17 Then s = 0.7: t = 1.4: r = 266.5
- ElseIf aLength = 16 Then s = 0.75: t = 1.5: r = 265.5
- ElseIf aLength = 15 Then s = 0.8: t = 1.6: r = 264.5
- ElseIf aLength = 14 Then s = 0.86: t = 1.7: r = 264
- ElseIf aLength = 13 Then s = 0.92: t = 1.8: r = 262
- ElseIf aLength = 12 Then s = 1: t = 2: r = 260
- ElseIf aLength = 11 Then s = 1.08: t = 2.3: r = 258.5
- ElseIf aLength = 10 Then s = 1.19: t = 2.5: r = 257
- ElseIf aLength = 9 Then s = 1.33: t = 2.8: r = 255
- ElseIf aLength = 8 Then s = 1.48: t = 3.1: r = 252
- ElseIf aLength = 7 Then s = 1.7: t = 3.5: r = 251
- ElseIf aLength = 6 Then s = 1.98: t = 3.9: r = 247
- ElseIf aLength = 5 Then s = 2.4: t = 4.9: r = 243
- ElseIf aLength = 4 Then s = 3: t = 5: r = 235
- ElseIf aLength = 3 Then s = 3.9: t = 5: r = 220
- Else
- MsgBox "印章有效汉字位数:3-30!", vbOKOnly + vbCritical, "电子印章"
- End If
- With ActiveDocument
- With .Shapes.AddTextEffect(msoTextEffect3, i, "宋体", 12!, msoFalse, msoFalse, 219.75, 103!) '去掉Select语句和Selection语句,大幅提高效率
- '艺术字(s=宽度缩放,t=稀疏,r=满圆)
- .TextEffect.Tracking = t
- .ScaleHeight 12, msoFalse, msoScaleFromTopLeft
- .ScaleWidth s, msoFalse, msoScaleFromTopLeft
- .Line.Weight = 0.25 '清晰
- .Adjustments(1) = r
- arr(1) = .Name
- End With
- With .Shapes.AddShape(msoShapeOval, 201.6!, 85!, 180!, 180!) '圆周
- .Fill.Transparency = 1!
- .Line.Weight = 3.5
- .Line.Style = msoLineThickThin
- arr(2) = .Name
- End With
- With .Shapes.AddShape(msoShape5pointStar, 264.3, 147.8, 54.9, 47.6) '五角星
- .Fill.ForeColor.RGB = RGB(255, 0, 0)
- .Line.Weight = 0.25
- arr(3) = .Name
- End With
- With .Shapes.AddShape(msoShapeRectangle, 259!, 197!, 66!, 24!) '附言
- arr(4) = .Name
- .Line.Visible = msoFalse
- .LockAspectRatio = msoTrue
- With .TextFrame
- .MarginLeft = 0
- .MarginRight = 0
- .MarginTop = 0
- .MarginBottom = 0
- With .TextRange
- .Text = "业务专用章"
- .ParagraphFormat.Alignment = wdAlignParagraphCenter
- .Font.Color = wdColorRed
- .Font.Bold = True
- .Font.Size = 7.5
- End With
- End With
- End With
- With .Shapes.Range(Array(arr(1), arr(2), arr(3), arr(4))).Group
- .LockAspectRatio = msoTrue '组合
- .Line.ForeColor.RGB = RGB(255, 0, 0) '设置颜色
- .ScaleWidth 0.5, msoFalse, msoScaleFromTopLeft '缩放
- .ScaleHeight 0.5, msoFalse, msoScaleFromTopLeft
- End With
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|