Home > Software engineering >  New beginner, word macro modify the font to use, probably around 10 w word at a time, fastest to 10
New beginner, word macro modify the font to use, probably around 10 w word at a time, fastest to 10

Time:03-15

Sub random imitate handwriting ()

Dim Ra As Range
Dim FontSize () As String
FontSize=Split (" 16.5, 16.5, 17, 18, ", "")
Dim FontName () As String
FontName=Split (" A1, A2, A3, A4, A5 ", ", ")
A=0
'a value to adjust font and the deviation of
B=1
'b value adjustment word spacing
'c=20
'c value to adjust the line spacing
For Each Ra In ActiveDocument. Characters
VBA. Randomize
FontNameLength=UBound (FontName) - LBound (FontName)
FontSizeLength=UBound (FontSize) - LBound (FontSize)
Ra. The Font. The Name=FontName (Int (VBA. Rnd * FontNameLength) + 1)
Ra. The Font. The Size=FontSize (Int (VBA. Rnd * FontSizeLength) + 1)
Ra. The Font. The Position=Choose (Int (VBA. Rnd * 0.5) + 1, 1, 0.5, 0, 0.5, 1) + a
Ra. The Font. Spacing=Choose (Int (VBA. The Rnd * 1) + 1, 1.5, 1, 0.5, 0, 0.5, 1, 2) + b
If Ra=", "the Or Ra=", "the Or Ra=";" The Or Ra="'" Or Ra="" Or" Ra="" "Or Ra="" "Or Ra="!" The Or Ra=":" Then
'Ra. The Font. The Name="A1"
Ra. The Font. The Size="14"
Ra. The Font. The Position="0.5"
Ra. The Font. Spacing="1"
'ElseIf Asc (Ra) & gt;=48 And Asc (Ra) & lt; 57 Then=
'Ra. The Font. The Name="J2, J3 and J4"
ElseIf Asc (Ra) & gt;=97 And Asc (Ra) & lt;=122 Or Asc (Ra) & gt;=65 And Asc (Ra) & lt;=90 Or Ra=". "Or Ra=" (" Or Ra=") "the Or Ra=" (" Or Ra=") "the Or Ra=" ~ "Then
'Ra. The Font. The Name="J1, J2, J3 and J4, J5, A1, A2, A3"
End the If
If Ra=". "Or Ra=" "Then
Ra. The Font. The Name="A3"
Ra. The Font. The Size="16.5"
Ra. The Font. The Position="0"
Ra. The Font. Spacing="0"
End the If
If Ra=", "the Or Ra=", "Then
Ra. The Font. The Name="A3"
Ra. The Font. The Size="16.5"
Ra. The Font. The Position="0"
Ra. The Font. Spacing="- 5"
End the If
If Ra="0" Or Ra=", "Then
Ra. The Font. The Size="11"
Ra. The Font. The Position="0"
Ra. The Font. Spacing="0"
End the If
If Ra="top" Then
Ra. The Font. The Name="W3
"Ra. The Font. The Size="16.5"
Ra. The Font. The Position="0"
Ra. The Font. Spacing="0"
End the If
Next

'For Each Ra In ActiveDocument. Paragraphs

'Ra. ParagraphStyle. LineSpacingRule=wdLineSpaceExactly
'Ra. ParagraphStyle. LineSpacing=Int (VBA. The Rnd * 1) + 1 + c
'Next


'With Selection. ParagraphFormat
'FirstLineIndent=CentimetersToPoints (0.35)
'CharacterUnitFirstLineIndent=0
'End With

Selection. The Find. ClearFormatting
Selection. The Find. Replacement. ClearFormatting
With the Selection. The Find
. The Text="" "
. Replacement. Text=""
The Forward=True
The Wrap=wdFindContinue
. The Format=False
. MatchWholeWord=False
. MatchByte=True
. MatchWildcards=False
. MatchSoundsLike=False
. MatchAllWordForms=False
End With
Selection. The Find. Execute2007 Replace:=ReplaceAll
Selection. The Find. ClearFormatting
Selection. The Find. Replacement. ClearFormatting
With the Selection. The Find
. The Text="" "
. Replacement. Text=""
The Forward=True
The Wrap=wdFindContinue
. The Format=False
The MatchCase=False
. MatchWholeWord=False
. MatchByte=True
. MatchWildcards=False
. MatchSoundsLike=False
. MatchAllWordForms=False
End With
Selection. The Find. Execute the Replace:=wdReplaceAll
Application. ScreenUpdating=False
End Sub



  •  Tags:  
  • VBA
  • Related