On 06/04/2013, at 10:38 AM, Rick Gordon <email@hidden> wrote:
That line generates an error: error "Invalid parameter." number 30477
One of the things that I suspect is causing problems is your use of unnecessary tell blocks, and some dangerously nested. They're convenient, but they can cause all sorts of problems, especially in InDesign, and especially when you are dealing with more than one document.
For example, your three unsuccessful approaches are all inside a "tell paragraph style vChosenItem" block. You should only include in that block stuff that relates to that paragraph style. If you don't, chances are ID will look for one of the properties you reference as belonging to a paragraph style, which will then generate an error. Nesting tell blocks to the application inside it is only going to make your code harder to debug, because it will resolve some references correctly, but not necessarily all. Just end your tell blocks when they're no longer doing anything useful for you. If you can't, because of a repeat, consider reworking your code.
So (untested, but you should get the idea):
set vDestParaStyleList to object reference of items 2 thru -1 of all paragraph styles of vDestDoc set vDestNameList to {} repeat with vItem in vDestParaStyleList tell vItem if class of parent is paragraph style group then set end of vDestNameList to name of parent & ": " & name else set end of vDestNameList to name end if end tell end repeat set vChosenItem to item 1 of (choose from list vDestNameList with prompt "Choose destination paragraph style to add GREP styles into.")
repeat with i from 1 to (count items in vGrepList) set vCurrentSourceGrepRef to item i of vSourceGrepRefList set vCharStyleName to name of applied character style of vCurrentSourceGrepRef set vDestAppliedCharStyle to (items of all character styles of vDestDoc where name is equal to vCharStyleName) if length of vDestAppliedCharStyle > 0 then set vDestAppliedCharStyle to item 1 of vDestAppliedCharStyle else set vDestAppliedCharStyle to (make new character style at end of vDestDoc with properties (get properties of applied character style of vCurrentSourceGrepRef)) end if make new nested grep style at end of vDestDoc with properties {applied character style:vDestAppliedCharStyle, grep _expression_:grep _expression_ of vCurrentSourceGrepRef} end repeat end tell
|