4 Replies Latest reply on Nov 26, 2008 5:44 AM by (Bian)

    How to get the Leading Value in VBAScript

      The default auto-leading option sets the leading at 120% of the type size (for example, 12-point leading for 10-point type). When auto-leading is in use, Larger text size of one word/Character in the Line increases leading for that one line.
      The problems are :
      1. why is the Value of the VBAscript myLine.Leading always equal to 1635019116(idLeading.idAuto), not 12 points (10 x 120%)?
      2. We know the Leading can be calculated by myLine.AutoLeading*myLine.PointSize when auto-Leading in in use. But Sometimes we can't get the Actual Leading When auto-Leading of the Paragraph is use(10-point type and 120%-AutoLeading):
      a. We manually set the Leading of some Character in the Line 30 points, the Leading of the Line increases to 30 points. But the myLine.Leading or myCharacter.Leading always equal to 1635019116(idLeading.idAuto), So we can't get the actual value of Leading(30 points) How to the actual Leading value?
      b. We we insert the inline/aboveline anchored object to the line text. If the Height of the anchored object is larger than myLine.AutoLeading*myLine(10*120%=12 points). It would increases leading for that one line. How to the actual Leading value?

      Brian
        • 1. Re: How to get the Leading Value in VBAScript
          Level 1
          The reason you get the auto enumeration is because that's what the leading is set to. It's up to you to do the calculation. But your assumption that you can use the line's leading value is false. You must use the specific character you're interested in.

          While internally, InDesign uses the maximum leading in use on the line for the line, when you get the line's leading from the Object Model, you actually get the leading of the first character of the line only. This might be why you are confused about sometimes getting the explicit value -- each character can have a different leading.

          I think this confusion about what the line.leading really returns is what is causing most of your confusion.

          Bear in mind that if you have an inline graphic in the line, the leading of the character holding the graphic is a more complicated calculation yet.

          Dave
          • 2. Re: How to get the Leading Value in VBAScript
            Level 1
            For example:(PointSize=10 and AutoLeading=120% of the Paragraphs)
            "Chinese president urges APEC members to boost economic integration, strengthen human security
            LIMA, Nov. 23 (Xinhua) -- Chinese President Hu Jintao on Sunday urged the Asia-Pacific Economic Cooperation (APEC) members to boost economic integration and strengthen human security in the region."

            When the Leading of "APEC" was set manually to 30 points in the Leading menu of the Character panel. The line's Leading that "APEC" is in will be increased to 30.

            Using the following VBAScript, We just can get MaxLeading =1635019116(idLeading.idAuto) and LinePointsize =10 and MaxLeading =120%. If we calculate the Leading by autleading*poinsize, the Leading will be 12, but the actual Leading is 30 points.

            myLineCharacterTotal = myLine.Characters.Count
            MaxLeading = 0

            For myCharacterCounter = 1 To myLineCharacterTotal
            Set myCharacter = myLine.Characters.Item(myCharacterCounter)
            myCharacterPointSize = myCharacter.PointSize
            myCharacterLeading = myCharacter.Leading
            myCharacterAutoLeading = myCharacter.AutoLeading

            If MaxLeading < myCharacterLeading Then
            MaxLeading = myCharacterLeading
            End If
            If MaxAutoLeading < myCharacterAutoLeading Then
            MaxAutoLeading = myCharacterAutoLeading
            End If
            If myLinePointSize < myCharacterPointSize Then
            myLinePointSize = myCharacterPointSize
            End If
            Next

            Brian