Placing text in an InDesign text box that reflows to multiple pages fails

Issue 1: Here’s my main problem: whenever I have a text frame connected to another one on a subsequent page (reflowed), using the InDesign place command to place a Word document causes my script to return “error -29442: Import failed.”

  • When the text frame isn’t linked to another text frame, it works fine. I need to be able to have it work with multiple linked text framers without failing, just like the manual place command in InDesign works. How would I do that?

Issue 2: Whenever I use either the set applied paragraph style or apply paragraph style commands, the script only sets the paragraph style for visible text in the frame. Overset text is not restyled. I would like to apply the paragraph style to all the text stored in that frame, or across multiple reflowed text frames, rather than just the visible text of the frame.

  • It doesn’t make any sense to me that this would be the behavior, even when I specify every paragraph of the text frame.

Issue 3: Despite specifying without clearing overrides, I’m finding that applying a paragraph style via AppleScript removes italics from text. Applying it via the InDesign user interface doesn’t do this unless I specifically select “clear overrides.” What gives?

Thank you for your help.

It would be good if you could post script samples that illustrate each issue as simply as possible.

Hi
try something like this

tell first insertion point of parent story of myTextFrame to place myWordFile

set applied paragraph style of parent story of myTextFrame to paragraph style “test” of active document

apply paragraph style (text of parent story of myTextFrame) using paragraph style “test” of active document without clearing overrides

1 Like

Wow, thank you so much @msv! You’ve gotten me nearly there. I really appreciate your help.

I have one remaining issue (which may be related to InDesign’s behavior, since applying the paragraph style manually to the text results in the same issue).

My paragraph style is defined using the medium weight of the font.

Thanks to you, now that I’m specifying without clearing overrides correctly, the italics are retained, which is great! But despite that the paragraph style is applied on unformatted text, any italicized text stays in regular italic, even though I’d like it to be medium italic. The rest of the non-italicized text does use the medium weight as defined by the style.

Of course, if I don’t specify without clearing overrides, the medium font weight is applied evenly, but then I obviously lose the italics.

Is there a way to retain both?

I think you have to do a find and replace before applying paragraph style

search for every text in regular italic and change to medium italic

Is there any way to script the find and replace?

yes of corse

--setup find preferences
set find what of find text preferences to nothing
set font style of find text preferences to "Italic"

--setup change preferences
set change to of change text preferences to nothing
set font style of change text preferences to "Medium Italic"

--make changes
change text active document

--reset find/change preferences
set font style of find text preferences to nothing
set font style of change text preferences to nothing
2 Likes

Thanks again for your help!

Somehow, I’m getting the error “Adobe InDesign 2021 got an error: Can’t set find what of find text preferences of text frame id [xxxxx] of spread id [xxxxx] of document id [xx] to nothing.” The error code is -10006.

Here’s the sample code.

tell active page of layout window 1 of active document
	set exampleFrame to text frame 1
		tell exampleFrame
			--setup find preferences
			set find what of find text preferences to nothing
			set font style of find text preferences to "Italic"
				
			--setup change preferences
			set change to of change text preferences to nothing
			set font style of change text preferences to "Medium Italic"
				
			--make changes
			change text active document
				
			--reset find/change preferences
			set font style of find text preferences to nothing
			set font style of change text preferences to nothing
		end tell
end tell

The find preferences belong to the Application, not the text frame. Try something like this:

tell application "Adobe InDesign CS6"
	find text preferences
	
	--setup find preferences
	set find what of find text preferences to "Text to find"
	
	set font style of find text preferences to nothing
	
	--setup change preferences
	set change to of change text preferences to "Text to find"
	set font style of change text preferences to "Medium Bold"
	

	--make changes
	tell active document
		change text
	end tell
	
	--reset find/change preferences
	set font style of find text preferences to nothing
	set font style of change text preferences to nothing
end tell
end
1 Like

Solved! Thank you both very much for your help. :slight_smile: