🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #19442

VB: Fit text to frame

#19442
From: David Ames
Date: Mon, 09 Dec 2002 01:43
34 lines
2306 bytes
Hey all,

I'm trying to come up with some VB code to fit text to frame in ID. So far I have the following:

Private Sub FitTextToBox(idTextFrame As InDesign.TextFrame, _
                         XMLTagName As String, _
                         MinFontPointSizeWhenFittingToBox As Long, _
                         MaxFontPointSizeWhenFittingToBox As Long, _
                         FontPointSizeToIncrimentByWhenFittingToBox As Long)

Dim NewPointSize As Variant

idTextFrame.Texts(1).PointSize = MinFontPointSizeWhenFittingToBox / 10
    If idTextFrame.OverFlows Then
      MsgBox ("Warning: The text for text box " & XMLTagName & " overflows the textbox at the mimimum font point size of " & CStr(Round((MinFontPointSizeWhenFittingToBox / 10), 1)))
    End If

For NewPointSize = (MinFontPointSizeWhenFittingToBox / 10) To (MaxFontPointSizeWhenFittingToBox / 10) Step (FontPointSizeToIncrimentByWhenFittingToBox / 10)
      idTextFrame.Texts(1).PointSize = NewPointSize
      If idTextFrame.OverFlows Then
        idTextFrame.Texts(1).PointSize = NewPointSize - (FontPointSizeToIncrimentByWhenFittingToBox / 10)
        If idTextFrame.OverFlows Then
          idTextFrame.Texts(1).PointSize = NewPointSize - (FontPointSizeToIncrimentByWhenFittingToBox / 10)
        End If
        Exit For
      End If
    Next

End Sub

This kind of works well, exept that
 idTextFrame.Texts(1).PointSize = only seems to change the PointSize of the visible text in the box, not the overflowed text.

Does anyone have a better method of doing what i'm trying to do?
Technical Details
Message-ID: <1de6ec84.-1@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!proxad.net!proxad.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,65bc686a8c431ae2,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-12-08 18:09:22 PST
From: "David Ames" <davida@in-site.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!proxad.net!proxad.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: VB: Fit text to frame
Message-ID: <1de6ec84.-1@WebX.la2eafNXanI>
Date: Sun, 8 Dec 2002 17:43:27 -0800
Lines: 44
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit