|
本帖最后由 loquat 于 2015-6-26 13:07 编辑
对21楼代码做简化。。。
- Sub 手写字体_loquat()
- Dim R_Character As Range, aRange As Range
- Application.ScreenUpdating = False
- For Each R_Character In ActiveDocument.Characters
- 'DoEvents '这样应该可以解决假死问题,但是较大地影响效率,虽然也可以用API降低其影响但是这里就不班门弄斧了。
- VBA.Randomize
- If InStr(1, "、。‘’“”!?", R_Character) > 0 Then '还可以加其他标点符号
- R_Character.Font.Name = Choose(Int(VBA.Rnd * 2) + 1, "方正静蕾简体", "书体坊安景臣钢笔行书")
- Else
- R_Character.Font.Name = "方正静蕾简体"
- End If
- '下面三行代码应该自己去更改
- R_Character.Font.Size = Choose(Int(VBA.Rnd * 7) + 1, "18", "17.5", "17", "19.5", "18.5", "19", "20")
- R_Character.Font.Position = Choose(Int(VBA.Rnd * 5) + 1, 1.5, 2.5, 2, 0, 1)
- R_Character.Font.Spacing = Choose(Int(VBA.Rnd * 5) + 1, -1.8, -1.5, -1.6, -1.7, -1.4)
- Next
- With Selection.Find
- .ClearFormatting
- .Replacement.ClearFormatting
- .Text = "[“”]"
- .Forward = True
- .Wrap = wdFindContinue
- .MatchWildcards = True
- .Execute Replace:=wdReplaceAll
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|