View Single Post
 
Old 06-13-2018, 02:25 PM
puff puff is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Question Oscillate position

Hi all! I'm developing a script to make a doc more hand-written like. I originally used randomization to alter the position of each character. Yet, the result is a bit weird since common people write in a line that is oscillating rather than random.
Here is the original code:
Code:
Sub HandWrittenSimulation()
Dim R_Character As Range
Dim ParagraphSpace(3)
    ParagraphSpace(1) = "11"
    ParagraphSpace(2) = "12"
    ParagraphSpace(3) = "13"
For Each R_Character In ActiveDocument.Characters
        VBA.Randomize
        R_Character.font.Position = Int(VBA.Rnd * 3) + 1
        R_Character.font.Spacing = 0
    Next
    Application.ScreenUpdating = True
   For Each Cur_Paragraph In ActiveDocument.Paragraphs
        Cur_Paragraph.LineSpacing = ParagraphSpace(Int(VBA.Rnd * 3) + 1)
    Next
        Application.ScreenUpdating = True
End Sub
As you can see, I randomize every character's font position as 11, 12, or 13. However, can I let a character to determine its paragraph space from the character before. Like if the previous character is 12, then itself can be either 11 or 13; if the previous one is 11, it can only be 13; if the previous one is 13, then it can only be 12. I will add more choices later such that a middle position can have more options, like for 11, 12, 13, 14, a character after a 12 can randomize if it's 11 (minus) or 13 (add).

Since I assume the natural paragraph will break the continuity, I think just randomize the 1st character of every paragraph should work.
Thank you very much XD

Last edited by puff; 06-13-2018 at 05:07 PM.
Reply With Quote