[InDesign] Can't get alias

I am trying to make a print publication from an online NFL picks contest we are running. I have set up AS to use JS to grab all the info and place it all in variables. Now I need to place the graphics into the table I have in InDesign. There are frames each with a script label that matches the variable in the AS

I have tried to do this two ways and I get the same error: InDesign can not get the alias


set theLogofolder to "Volumes/SpecialSections/Special Pages A-G/Football Challenge 2011/1 Logos/" --Has PDFs of every NFL team LOGO named ATL.pdf, GB.pdf, etc...

--game1vip1 -> GB --because they picked Green Bay 
set theLogo to (game1vip1 as string) & ".pdf"
set theImage to ((theLogofolder as string) & (theLogo as string) as alias)


tell application "Adobe InDesign CS4"
	activate
	tell rectangle "game1vip1" of page 1 of document 1
		place theImage --Errors
	end tell
end tell



Next try:


set theLogofolder to "Volumes/SpecialSections/Special Pages A-G/Football Challenge 2011/1 Logos/" --Has PDFs of every NFL team LOGO named ATL.pdf, GB.pdf, etc...

--game1vip1 -> GB --because they picked Green Bay 

tell application "System Events"
	set these_files to every file of folder theLogofolder
end tell
repeat with i from 1 to the count of these_files
	set this_file to (item i of these_files as alias)
	set this_info to info for this_file
	if visible of this_info is true and alias of this_info is false then
		if name of this_info contains game1vip1 then
			
			tell application "Adobe InDesign CS4"
				activate
				tell rectangle "game1vip1" of page 1 of document 1
					place this_file  --Errors
				end tell
			end tell
		end if
	end if
end repeat

Another thought I had to solve it was to rename the script labels (using the script) to the value.
Something like:


tell application "Adobe InDesign CS4"
    set label of rectangle "game1vip1" to game1vip1  --error
end tell

Another issue is the way I set this up to begin with:

tell application "Adobe InDesign CS4"
	set thislabel to label of every rectangle of page 1 of document 1
end tell

--> {"Game16VIP6", "Game15VIP6", "Game14VIP6", "Game13VIP6", "Game12VIP6", "Game11VIP6", "Game10VIP6", "Game9VIP6", "Game8VIP6", "Game7VIP6", "Game6VIP6", "Game5VIP6", "Game4VIP6", "Game3VIP6", "Game2VIP6", "Game1VIP6", "Game16VIP5", "Game15VIP5", "Game14VIP5", "Game13VIP5", "Game12VIP5", "Game11VIP5", "Game10VIP5", "Game9VIP5", "Game8VIP5", "Game7VIP5", "Game6VIP5", "Game5VIP5", "Game4VIP5", "Game3VIP5", "Game2VIP5", "Game1VIP5", "Game16VIP4", "Game15VIP4", "Game14VIP4", "Game13VIP4", "Game12VIP4", "Game11VIP4", "Game10VIP4", "Game9VIP4", "Game8VIP4", "Game7VIP4", "Game6VIP4", "Game5VIP4", "Game4VIP4", "Game3VIP4", "Game2VIP4", "Game1VIP4", "Game16VIP3", "Game15VIP3", "Game14VIP3", "Game13VIP3", "Game12VIP3", "Game11VIP3", "Game10VIP3", "Game9VIP3", "Game8VIP3", "Game7VIP3", "Game6VIP3", "Game5VIP3", "Game4VIP3", "Game3VIP3", "Game2VIP3", "Game1VIP3", "Game16VIP2", "Game15VIP2", "Game14VIP2", "Game13VIP2", "Game12VIP2", "Game11VIP2", "Game10VIP2", "Game9VIP2", "Game8VIP2", "Game7VIP2", "Game6VIP2", "Game5VIP2", "Game4VIP2", "Game3VIP2", "Game2VIP2", "Game1VIP2", "Game16VIP1", "Game15VIP1", "Game14VIP1", "Game13VIP1", "Game12VIP1", "Game11VIP1", "Game10VIP1", "Game9VIP1", "Game8VIP1", "Game7VIP1", "Game6VIP1", "Game5VIP1", "Game4VIP1", "Game3VIP1", "Game2VIP1", "Game1VIP1", "", "", "", "", "", "", "", "", "ad5", "ad4", "ad2", "ad3", "ad1", ""}

For every label there is also a corresponding variable in the AS…
I REALLY need a way to cycle through the variables and nothing works…Dynamic variable names seems to be a dream in AS

repeat with v from 1 to 2
	repeat with g from 1 to 2
		--set this_pick to "Game" & v & "VIP" & g
		set this_logo to "game" & v & "vip" & g
		set this_logo to value of this_logo
		
	end repeat
end repeat

Any help on any of my issues would be greatly appreciated

Hi,

just use a macPath …

set theLogofolder to "SpecialSections:Special Pages A-G:Football Challenge 2011:1 Logos:"

Bye

Hans-Gerd Claßen

It wasn’t as simple as changing to a macpath (which I had tried)

set theLogofolder to "SpecialSections:Special Pages A-G:Football Challenge 2011:1 Logos:"

set Logo_Name to "GB" -- Another sting variable
set This_Label to "game1vip1"

try
	set This_Logo to (theLogofolder & Logo_Name & ".pdf") --as alias -- Concat the strings then coerce
	-- If an 'alias' was made then the file exists
	my placeFile(This_Label, This_Logo)
on error
	display dialog "Hum. The File Does Not Exist.?" giving up after 3
end try

-- Pass your name string & file alias
on placeFile(This_Label, This_Logo)
	tell application "Adobe InDesign CS4"
		activate
		tell document 1
			tell page 1
				tell (the first rectangle whose label is This_Label)
					place This_Logo
					
					fit given proportionally
					fit given center content
				end tell
			end tell
		end tell
	end tell
end placeFile

Now to work out how to get the dynamic variable name

Hi,

guess it was that simple :wink: but never mind …

Tipp:
Have a look at the SampleErrorHandlingFiles of Apple.
Because:
Creating a own errormessage which just expects an specific error may give a wrong information …

Have a nice day :slight_smile: