It’s had been been working fine for months now but recently (after I upgraded to 10.5) my script started throwing errors at set lImageItems to (page items whose label contains “IMG”). I have trimmed out all of the fat from the script below leaving only the bits that are necessary and have tried everything I can think of (moving line inside different tell blocks, substituting rectangles, graphics, images etc. for page items, adding a tell layer"Images" block…) but I’ve got squat. I have checked the InDesign document to make sure the labels are still there and that all of the page items are getting unlocked and everything looks good there. Any ideas?
This is the stripped down script:
tell application "InDesign CS"
open alias ("Macintosh HD:Users:eric:Desktop:dmt0001.indd") as Unicode text
set lProjectDocument to active document
tell lProjectDocument
set lImageLayer to layer "Images"
set lPageList to pages as list
set lImageItems to {}
repeat with i from 1 to (count lPageList) -- Get number of pages in job
tell page i
set gPageMaster to ("CAT-001") as string -- Get the master ID from gInfoDump
tell application "InDesign CS"
tell active document
if gPageMaster ≠"Blank" then
set lMaster to master spread gPageMaster
tell page i to set properties to {applied master:lMaster} -- Apply master page to active page
override master page items of page i destination page page i -- Unlock the items for editing
end if
end tell
end tell
set lImageItems to (page items whose label contains "IMG") -- <**********************************
end tell
end repeat
end tell
end tell
This is the contents of the Event Log:
Model: Mini - PPC
AppleScript: 2.0
Browser: Firefox 2.0.0.13
Operating System: Mac OS X (10.5)
Try this (I no longer have CS so it could be different) I had to do a rewrite for CS3 on Leopard myself.
CS2 I know this works and when I switched to Leopard I had to wrap the code with tell document 1. Personally I use document over active document due to some buggy behavior in InDesign.
tell application "Adobe InDesign CS"
tell document 1
set myPageItems to every page item whose label starts with "IMG"
end tell
end tell
Also when I unlock master page items I call the items from the master page and set the destination page
tell application "Adobe InDesign CS"
tell document 1
override every page item of master spread myMasterPage destination page last page
end tell
end tell
Well neweller, I gave it a try with just the code you see below but again got no results. No errors…just no results.
Now if I were to change to active document or active page or even if I inserted tell layer “Images” I get errors. But “InDesign CS got an error: Can’t get every page item of layer "Images" of page 1 of document 1 whose label starts with "IMG".” (for example) has yet to give me the flash of insight I need to fix this. I will be going through this again when I move to CS3 also, but for now I am forced to toil under CS. At least it isn’t 1.0.
Honestly nothing stands out in your code besides what I mentioned(which were minor issues). And if you think back what has changed
the only logical step I would go down would be an uninstall and reinstall of InDesign. If you have used this code with no problems and a OS update breaks the code I would at least try to reinstall the app.
Only other suggestion would be using a newer version of InDesign.
BTW I ran your code in InDesign CS2 with no problems. myPageItems returns all items with label “IMG”.
I think the problem your having is due to a bug, i tested this a bit and got just like yourselves
the dreaded empty list {}
however i opened up CS2 and tested it through there and it returned a reference to the page item.
so i had both indesigns open at the same time and then quit out of the CS2 version and all of a sudden CS3 is giving me the file reference
infact i couldn’t get the script to fail after this, i tried everything but a restart of my mac.
whether this could be useful to you or not i don’t know!!
I manually deleted all of the com.adobe.xxx files in the user/library/preferences folder because I could NOT get the installer to run past the EULA until I did. After I rebooted I managed to get he CS applications re-installed but after a reboot I STILL get nothing other than an empty list. I have run through every maintenance procedure I can think of including flushing the DNS cache (that’s how desperate I am) and still nothing.
I posted on the Adobe forum and hopefully this will be a known issue that somebody can help with. I’m wondering if this has anything to do with upgrading from applescript 1.x to 2.0?
Did you try going through the steps manually, and then testing the document (not the page) to see if the labeled frames will register? Are they on a layer? I ask because your script references an “Images” layer, but does nothing with it after the first mention.
I’m not certain that this has any bearing on the problem, but I don’t believe a master spread would be “Blank” unless you specifically named a new one this, yourself; the standard blank master has nothing as its value. It looks like the outcome of your PageMaster test will always be that it does not equal.
Yes I have and no, they don’t. They are all on the layer “Images” but even though I do set the variable for the layer I never really use it so it is vestigial and needs to be removed. That is usually the last step for me, cut out the dead bits. As for “Blank” it is a name I assign in another script and has a use.
As for the problem at hand I have put the script on a machine with CS3 on it and surprise, it works just fine. I am pretty sure this is an issue with CS and 10.5.2 but I can’t see where. I am guessing that I could fix this with a clean install of the OS and then an install of the CS suite but I REALLY don’t want to do that again.
Thanks for the suggestion Marc. I am going to help my brother move tomorrow and then we are heading north to our secret morel hunting grounds to look for mushrooms. I have been hearing the call of the black morels for the last few days and MUST go look. :rolleyes:
I will probably be able to check this on tuesday or there abouts.