Article View: adobe.scripting.indesign
Article #20544Re: Insertion points?
From: Olav Kvern
Date: Tue, 18 Jun 2002 19:34
Date: Tue, 18 Jun 2002 19:34
76 lines
3935 bytes
3935 bytes
Mike--
Here's one method for doing what you want. I don't like it, because it relies on selection and copy/paste:
Rem Given an InsertionPoint "myInsertionPoint" and a TextFrame "myTextFrame"...
myInDesign.Select myTextFrame, False
myInDesign.Cut
myInDesign.Select myInsertionPoint
myInDesign.Paste
Rem Get a reference to the inline frame.
Set myInlineFrame = myInsertionPoint.ParentTextFrame.ParentStory.Characters.Item(myInsertionPoint.Index - 1).Inlines.Item(1)
Rem Get the height of the frame from its geometric bounds.
myGeometricBounds = myInlineFrame.GeometricBounds
myY1 = myGeometricBounds(0)
myY2 = myGeometricBounds(2)
myHeight = myY2 - myY1
Rem Resize the frame.
myInlineFrame.GeometricBounds = Array(myY1 + myHeight, myGeometricBounds(1), myY2 + myHeight, myGeometricBounds(3))
A better method, in my opinion, is to create the inline frame by creating and then placing a dummy EPS that's the width and height you want:
Rem Given an InsertionPoint "myInsertionPoint," and the width and height of the inline frame as "myWidth" and "myHeight"
myFileName = "c:\myTestEPS.eps"
Rem Width and height must be in points.
myMakeEPS myFileName, myWidth, myHeight
Rem Turn user interaction off to avoid the EPS import dialog box
myInDesign.UserInteractionLevel = idDontDisplayAlerts
Rem Place the dummy EPS inline.
Set myInlineFrame = myInsertionPoint.Place(myFileName)
Rem Turn user interaction back on again
myInDesign.UserInteractionLevel = idDisplayAlerts
Set myEPS = myInlineFrame.Item(1)
Set myInlineFrame = myEPS.Parent
Rem Remove the placeholder EPS
myEPS.Delete
Rem Convert the rectangle to a text frame
myInlineFrame.ContentType = idText
Rem Get the height of the frame from its geometric bounds.
myGeometricBounds = myInlineFrame.GeometricBounds
myY1 = myGeometricBounds(0)
myY2 = myGeometricBounds(2)
Rem You might want to subtract the leading amount from the following
myHeight = myY2 - myY1
Rem Resize the frame.
myInlineFrame.GeometricBounds = Array(myY1 + myHeight, myGeometricBounds(1), myY2 + myHeight, myGeometricBounds(3))
Rem At this point, you're ready to move the text into the inline frame
End Sub
Rem Here's the sub that creates the dummy EPS.
Private Sub myMakeEPS(myFileName, myWidth, myHeight)
Rem Project must include a reference to the Microsoft Scripting Runtime object SCRRUN.DLL
Dim myFileSystemObject As FileSystemObject
Dim myFile As TextStream
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
Set myFile = myFileSystemObject.CreateTextFile(myFileName)
myFile.WriteLine "%!PS-Adobe-2.0 EPSF-1.2"
myFile.WriteLine "%%BoundingBox: 0 0 " & CStr(myWidth) & " " & CStr(myHeight)
myFile.WriteLine "%%Creator:(InDesign script)"
myFile.WriteLine "%%Title:(dummy eps)"
myFile.WriteLine "%%EndComments"
myFile.WriteLine "newpath"
myFile.WriteLine "0 0 moveto"
myFile.WriteLine "0 " & CStr(myHeight) & " lineto"
myFile.WriteLine CStr(myWidth) & " " & myHeight & " lineto"
myFile.WriteLine CStr(myWidth) & " 0 lineto"
myFile.WriteLine "closepath"
myFile.WriteLine "%%End of file"
myFile.Close
End Sub
Hope this helps!
Thanks,
Ole
Technical Details
Message-ID:
<ef92471.6@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef92471.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,d17bc06bfa9ea738 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-06-18 12:43:48 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Insertion points? Message-ID: <ef92471.6@WebX.aaQKaf7vad4> Date: Tue, 18 Jun 2002 12:34:56 -0700 References: <ef92471.-1@WebX.aaQKaf7vad4> Lines: 85 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit