2 Replies Latest reply on Nov 23, 2017 10:52 PM by rouxer

    Randomly assign font to characters



      I'm trying to figure out a way to randomly assign one of a set of fonts to each character in the document.
      I've searched the internet and found the below script that is supposed to work for Microsoft Word (I'm still a novice when it comes to scripting, and the script is sort of old, so I haven't succeeded in making it work).

      I wanted to see if anyone knew of a way to use this concept and adapt a script for InDesign that would randomly assign a font to each character in the document from a list of fonts.


      Set objWord = CreateObject("Word.Application")

      objWord.Visible = True



      Set objDoc = objWord.Documents.Open("C:\Scripts\Test.doc")



      Set objRandom = CreateObject("System.Random")



      intLow = 1

      intHigh = 5



      Set objRange = objDoc.Range()

      Set colCharacters = objRange.Characters



      For Each strCharacter in colCharacters

          intRandom = objRandom.Next_2(intLow,intHigh)


          Select Case intRandom

              Case 1 strCharacter.Font.Name = "Arial"

              Case 2 strCharacter.Font.Name = "Times New Roman"

              Case 3 strCharacter.Font.Name = "Courier New"

              Case 4 strCharacter.Font.Name = "Forte"

          End Select



      Any help is greatly appreciated!!