🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15326

Re: [VB] Placing files and display filename.

#15326
From: Raymond_Messier
Date: Mon, 08 Dec 2003 18:00
71 lines
3831 bytes
'Here you go

Const MAX_ROWS				= 10
Const idPlaceholderText = &H50487478
Const idLeading 			= &H4D4C646F
Const idAtBeginning		= &H62676E67
Const idPageOrigin		= &H5243506F
Const idContentToFrame	= &H63746F66
Const idProportionally	= &H636F6E70
Const idFrameToContent	= &H636F6E70
Const idCenterContent	= &H63656E63

'Place all of the files in a folder in a table
Dim myInDesign ' As InDesign.Application
' You must add the Microsoft Scripting Runtime to the project to use this example

	Set myInDesign = CreateObject("InDesign.Application.2.0")
	Set myDocument = myInDesign.Documents.Add
	myDocument.ViewPreferences.RulerOrigin = idPageOrigin
	myX1 = myDocument.Pages.Item(1).MarginPreferences.MarginLeft
	myY1 = myDocument.Pages.Item(1).MarginPreferences.MarginTop
	myX2 = myDocument.DocumentPreferences.PageWidth - myDocument.Pages.Item(1).MarginPreferences.MarginRight
	myY2 = myDocument.DocumentPreferences.PageHeight - myDocument.Pages.Item(1).MarginPreferences.MarginBottom
	Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
	myTextFrame.GeometricBounds = Array(myY1, myX1, myY2, myX2)

	'Set tfp = myTextFrame.textframepreferences
	'tfp.columncount = 3
	'tfp.usefixedcolumnwidth = true
	'tfp.fixedcolumnwidth =

	Set myTable = myTextFrame.ParentStory.Tables.Add
	Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
	' Fill in the name of the folder containing the graphics you want to place.
	Set myFolder = myFileSystemObject.GetFolder("f:\highres")
	myTable.ColumnCount = 2
	myTable.Columns.Item(1).Width = "12p"
	myTable.Columns.Item(2).Width = "24p"
	'myTable.RowCount = myFolder.Files.Count
	myTable.RowCount = MAX_ROWS
	myCounter = 1
	For Each objFile In myFolder.Files
		Set myCell = myTable.Rows.Item(myCounter).Cells.Item(1)
		Set myInsertionPoint = myCell.InsertionPoints.Item(1)
		Set myGraphic = myInsertionPoint.Place(objFile.Path)
		Set myGraphic = myGraphic.Item(1).Parent
		nCellWidth = nCell.Width
		nBounds = nGraphic.GeometricBounds
		nX1 = nBounds(1)
		nY1 = nBounds(0)
		nX2 = nBounds(1) + nCellWidth - (nCell.LeftInset + nCell.RightInset)
		nY2 = nBounds(0) + nCellWidth - (nCell.LeftInset + nCell.RightInset)
		nGraphic.GeometricBounds = Array(nY1, nX1, nY2, nX2)
		nGraphic.Fit idContentToFrame
		nGraphic.Fit idProportionally
		nGraphic.Fit idFrameToContent
		' Add the graphic file name to the second cell.
		Set myInsertionPoint = myTable.Rows.Item(myCounter).Cells.Item(2).InsertionPoints.Item(1)
		myInsertionPoint.TextContents = objFile.Name	'objFile.Path
		' If we've run out of room on the page, add another page.
		If myInsertionPoint.Parent.Parent.Parent.OverFlows = True Then
			Set myPage = myDocument.Pages.Add
			Set myTextFrame = myPage.TextFrames.Add
			myTextFrame.GeometricBounds = myDocument.Pages.Item(myPage.DocumentOffset - 1).TextFrames.Item(1).GeometricBounds
			myTextFrame.PreviousTextFrame = myDocument.Pages.Item(myPage.DocumentOffset - 1).TextFrames.Item(1)
		End If
		myCounter = myCounter + 1
		If myCounter > 10 Then
			Exit For
		End If
	Next 'objFile
Technical Details
Message-ID: <2ccec26a.0@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccec26a.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,6cab27284b2180b5
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-12-08 10:08:01 PST
From: Raymond_Messier@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: [VB] Placing files and display filename.
Message-ID: <2ccec26a.0@webx.la2eafNXanI>
Date: Mon, 8 Dec 2003 10:00:57 -0800
References: <2ccec26a.-1@webx.la2eafNXanI>
Lines: 78
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit