Thursday, September 2, 2010

#1 2010-03-08 04:11:23 pm

Paeon
Member
From: Chicago
Registered: 2005-11-01
Posts: 68
Website

Need a small fix InDesign Applescript

Hi,
I wrote a tiny script to turn any empty text boxes in an ID doc to Unassigned content.

Applescript:

tell application "Adobe InDesign CS3"
   tell active document
       set myTextframes to every text frame
       repeat with i from 1 to count of myTextframes
           if contents of text frame i = "" then
               set (content type) of text frame i to unassigned
           end if
       end repeat
   end tell
   end tell

It works, except it always displays a message: Adobe InDesign CS3 got an error: Can't get contents of text frame (number) of active document. It doesn't matter to me, since I know that the script works. But someday I'd like to share this with others. Any idea why I get this error?

AppleScript: 2.11
Browser: Firefox 3.5.8
Operating System: Mac OS X (10.5)

Offline

 

#2 2010-03-08 07:23:23 pm

Marc Anthony
Member
From: Dallas, TX
Registered: 2006-04-27
Posts: 178

Re: Need a small fix InDesign Applescript

Hi. You're looping through indexes and then altering their state; at some point, the item ceases to exist. You could avoid the error by looping in reverse, but this can be expressed without looping.

Offline

 

#3 2010-03-08 08:08:48 pm

Jerome
Member
From: Ohio
Registered: 2003-06-13
Posts: 672
Website

Re: Need a small fix InDesign Applescript

Without looping through the text frames you can use the following:

Applescript:

tell application "Adobe InDesign CS3"
   tell active document
       set (content type) of every text frame whose contents is "" to unassigned
   end tell
end tell

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.149 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)