Indesign CS3 crashes when calling for properties

Hi there.

I have a bunch of InDesign scripts that do things like toggles rule above/below on and off, toggles between different color swatches and so on. They have worked fine in InDesign CS1, but ever since I upgraded to CS3 they crash the application when used on a PARTIALLY SELECTED paragraph formatted with a paragraph style using NESTED STYLES.

For instance, if I want to toggle the color of one word in the midst of a paragraph formatted with a paragraph style containing a nested style and run the script the program quits. Since the scripts are assigned to keyboard shortcuts that are firmly placed in muscle memory I accidentaly crash the app at least five times a day.

In my testing I have found that calling for properties on a selection with the aforementioned prerequisites crashes InDesign. So a simple “get properties of selection” crashes the app. However, if the entire paragraph is selected everything works fine. I have changed some of my scripts (like toggling the rule above on/off) to select the entire paragraph before changing the properties. But it doesn’t work with the color script, since I want to change the color of the selection, not the entire paragraph.

I use the Swedish version of InDesign and am curious if the bug is reproducable on english versions as well. I have tried it out on different computers, and the bug is 100 per cent reproducable on different systems containing Swedish language InDesign. It crashes. Period. Try blocks make no difference.

Can someone please try the script below (on a word in a paragraph formatted with a style using nested style) and tell me if it works or fails on an english system. If so, does anyone have a workaround?

/backelin


tell application "Adobe InDesign CS3"
	tell front document
		repeat with theItem in the selection
			
			if properties of theItem contains {fill color:swatch "Black"} then
				
				set properties of theItem to {fill color:swatch "Paper"}
			else if properties of theItem contains {fill color:swatch "Paper"} then
				set properties of theItem to {fill color:swatch "None"}
			else if properties of theItem contains {fill color:swatch "None"} then
				set properties of theItem to {fill color:swatch "Black"}
			else
				-- changes the color to black if any other color than paper, none or black is used
				set properties of theItem to {fill color:swatch "Black"}
			end if
		end repeat
		
	end tell
	
end tell

Model: Imac 24"
Browser: Safari 531.9
Operating System: Mac OS X (10.5)

Some things have changed from CS1 to CS3 so expect scripts to require some tweeking. I reworked your script a bit and came up with this:

tell application "Adobe InDesign CS3"
	set theSelection to selection
	tell document 1
		repeat with theItem in the selection
			set theFill to fill color of theItem
			if theFill is swatch "Black" then
				set fill color of theItem to swatch "Paper"
			else if theFill is swatch "Paper" then
				set fill color of theItem to swatch "None"
			else
				set fill color of theItem to swatch "Black"
			end if
		end repeat
	end tell
end tell

That did the trick!

Thank you very very super much!

I have had this problem for well over two years. And even though the problem was driving me nuts, I have been too shy to post a question at macscripter. I finally gave in and the solution was there within a couple of hours. I guess I learned something more besides better applescripting today.

/backelin