This content has been marked as final. Show 2 replies
It looks to me like you're placing all of the graphics on the first page:
Set myGraphic = myDocument.Pages.Item(1).Place (myFile)
I think what you want is to get the page containing the relevant text frame, then tell that page to place the graphic. As long as the text frame is not within a group, pasted into text as an inline/anchored frame, or inside another page item, the parent of the text frame will be the page. If that's the case, then something like this will work:
Rem Given a text frame "myTextFrame"
Set myPage = myTextFrame.Parent
...and then you should be good to go.
Thanks! Below is what I have now, it seems to work correctly, not sure if it's exactly what you intended. I have another page related question.
How would I find the last page of placed text in a document (treaded text frames) so that I can use it to set the page range in print perferences? The document has 20 pages of frames, but each time it's used, the number of pages with data can be different. If I should start a new post of this please let me know.
Rem PLACE GRAPHICS
Function myPlaceGraphics (myDocument)
For I = 1 to myDocument.TextFrames.Count
Set myCurrentFrame = myDocument.TextFrames.Item(I)
myCharacterCount = MyCurrentFrame.Characters.Count
If myCharacterCount > 0 Then
If left(myCurrentFrame.Texts.Item(1).Contents,7) = "[place=" Then
myFile = Mid(myCurrentFrame.Texts.Item(1).Contents,8)
myFile = Split(myFile,"]")(0)' get all to "]"
Set myLastCharacter = myCurrentFrame.Characters.Item(7 + Len(myFile) + 1)
Set myGraphic = myCurrentFrame.Parent.Place (myFile)
Set myGraphic = myGraphic.Item(1)
Set myRectangle = myGraphic.Parent
myGraphicBounds = myRectangle.GeometricBounds
myGraphicWidth = myGraphicBounds(3) - myGraphicBounds(1)
myGraphicHeight = myGraphicBounds(2) - myGraphicBounds(0)
myFrameBounds = myCurrentFrame.GeometricBounds
myFrameWidth = myFrameBounds(3) - myFrameBounds(1)
myFrameHeight = myFrameBounds(2) - myFrameBounds(0)
myRectangle.GeometricBounds = myFrameBounds
myRectangle.StrokeWeight = 0
myRectangle.FillColor = myDocument.Swatches.Item("None")
If myGraphicWidth > myFrameWidth or myGraphicHeight > myFrameHeight Then