Friday, November 16, 2018

#1 2018-11-07 06:55:41 am

Krayframe
Member
Registered: 2018-06-12
Posts: 5

Applescript InDesign Grep Script - Needs updating

Hi All.

I had an applescript that was working in Indesign 2015, however, I've returned to use it with Indesign 2018 and it keeps intermittently failing.

The script would set find / change values, search the doc and return the text found, I would then use this text to form the file name for saving.

Applescript:


tell application "Adobe InDesign CC 2015"
   activate
   
   set myFindGrep to ".+"
   set mySelectedParaStyle to "DM Product Code Split"
   --
   --
   set find what of find grep preferences to myFindGrep
   set applied paragraph style of find grep preferences to mySelectedParaStyle as string
   --
   --
   set MyFoundWords to find grep
   --
   --
   repeat with i from 1 to count MyFoundWords
       set MyFoundWordsList to MyFoundWordsList & item i of MyFoundWords
   end repeat
   --
   set lastInList to count MyFoundWordsList
   
   set mySave to (myDesktopJobFolderPath & (item lastInList of MyFoundWordsList) & ".indd")
   
end tell

I'm getting a couple of different errors on the line…

Applescript:

set MyFoundWordsList to MyFoundWordsList & item i of MyFoundWords

Error 1:
Can’t make text from character 1 to character 8 of story id 332 of document id 603 of application "Adobe InDesign CC 2018" into type vector.

Error 2:
Can’t make text from character 1 to character 6 of story id 331 of document id 611 of application "Adobe InDesign CC 2018" into type vector.

The text it's searching is just alpha/numeric codes, no special characters.



thanks

Shane

Last edited by Krayframe (2018-11-07 06:56:03 am)


Filed under: grep, Indesign, applescript

Offline

 

#2 2018-11-07 06:43:12 pm

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

Re: Applescript InDesign Grep Script - Needs updating

Hi. If the problem is intermittent and didn’t occur with the prior version, it could be a bug, however, the variable, MyFoundWordsList, isn’t defined in your posted code, and the erroring line actually shouldn’t exist; remove the repeat loop and change the preceding line to:

	set MyFoundWords to (find grep)'s contents

Offline

 

#3 2018-11-08 02:52:00 am

Krayframe
Member
Registered: 2018-06-12
Posts: 5

Re: Applescript InDesign Grep Script - Needs updating

Hi Marc

Thanks for the reply.

Apologies, I pulled this from a bigger script and left out the setting of 'MyFoundWordsList'

I've tried adding your line, but I receive an error of…

Can’t make item 0 of {} into type Unicode text.

Like you say it could just be a bug in the newer versions of ID, I just can't figure out why it's erroring on some text and not others.

Offline

 

#4 2018-11-08 07:13:46 am

Krayframe
Member
Registered: 2018-06-12
Posts: 5

Re: Applescript InDesign Grep Script - Needs updating

All sorted, a restart has fixed it roll

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)