View Single Post
 
Old 06-13-2018, 07:24 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I don't see the point of variation in the line spacing. If it was imaginary handwriting then I choose to imagine that the writer was following the pale blue lines on the page which don't vary.

A more realistic variation would be to vary the font size from character to character within a band. If you did this then it is simple to just let the paragraph spacing use whatever the font size is on the paragraph mark (since this is varied by the code too)

Code:
Sub HandWrittenSimulation()
  Dim arrPattern() As String, lngChar As Long, iPattCount As Integer, iScale As Integer, aPar As Paragraph
  arrPattern = Split("0,1,1,1,2,2,2,3,3,3,4,4,4,3,3,3,2,2,2,1,1,1,0,0", ",")
  iPattCount = UBound(arrPattern) + 1
  iScale = ActiveDocument.Characters(1).Font.Size
  ActiveDocument.Range.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
  
  For lngChar = 1 To ActiveDocument.Characters.Count
    ActiveDocument.Characters(lngChar).Font.Position = Int(VBA.Rnd * iScale / 10 + arrPattern(lngChar Mod iPattCount))
    ActiveDocument.Characters(lngChar).Font.Size = Int(2 * (iScale - 1) + (VBA.Rnd * 5)) / 2
  Next lngChar
End Sub
Note for future reference: By default, arrays start at zero so declaring it as
Dim ParagraphSpace(3)
means that there are 4 possible array positions (0, 1, 2, 3) but you ignore the first position.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote