Call jscript in a applescript in indesign CS5

Hello there,

I’m running a Applescript (a part of it is below) which does a number of things.
The part what I can’t figure out is the following.
After the Indesign-file (CS5) is opened and the word-file is imported in de textframe ‘artikel’ I need to run a jscript which is in Indesign in the scriptpanel called “preptext.jsx”.

When I run this script manually it is necessary to put the cursor in the textframe (called artikel).
How do I do that in the applescript?

Furthermore I keep on getting a error on the jscript-path. (file not found).
I checked the path numerous times but it’s correct, or does the single quote in “Programma’s” fucks it up?

Maybe one of you genius can give me a hand with this.

Thanks in advance.

Erwin

===============================================

tell application "Adobe InDesign CS5"
	set user interaction level of script preferences to never interact
	set myDocument to open templatePath
	set myPage to page 1 of myDocument
	
	-- search textframe with label 'artikel'
	repeat with i from 1 to count of page items of myPage
		if label of page item i of myPage is "artikel" then
			set myTextFrame to page item i of myPage
			exit repeat
		end if
	end repeat
	
	tell insertion point -1 of myTextFrame
		place importFile without showing options
	end tell
	
	tell myTextFrame to activate
	
	set aScriptPath to "Macintosh PPMG:Programma's:Adobe InDesign CS5:Scripts:Scripts Panel:preptext.jsx" as alias
	tell application "Adobe InDesign CS5"
		do script aScriptPath language javascript
	end tell
	
end tell

I haven’t tested you script but right off the top you have a tell app inside another tell app that won’t do you any good for a starter. And you activate apps and select objects ( not always required ).

hi,

works fine for me, so give it a try …

set templatePath to choose file
set importFile to choose file
set aScriptPath to choose file --to check if you're path is really correct ;-) copy paste it from answers in SE


tell application "Adobe InDesign CS5.5"
	set user interaction level of script preferences to never interact
	set myDocument to open templatePath
	set myPage to page 1 of myDocument
	
	--no need for any repeat loop ;-)
	set myTextFrame to text frame 1 of myPage whose label is "artikel"
	
	tell insertion point -1 of myTextFrame
		place importFile without showing options
	end tell
	
	--set the cursor at start ...
	select insertion point 1 of myTextFrame
	
	
	--gives me a 'hello world' ;-)
	do script aScriptPath language javascript
	
end tell

Yeah that look much more like it. I always prefer to set paths etc. Outside a tell app block then pass on. I also would have whose filtered I forgot to mention that.

Thanks guys,

This was a great help!
Although there was not so much difference with my attempt and “the real thing” I figured out what the problem was.
The path uses the english names of some folders instead of the names shown in the language of your system.
So the foldername “Programma’s” that I used had to be “Applications” in the path.

Thanks again !

Erwin