• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: INDESIGN: Duplicating Char Style from One Doc to Another
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: INDESIGN: Duplicating Char Style from One Doc to Another


  • Subject: Re: INDESIGN: Duplicating Char Style from One Doc to Another
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 06 Apr 2013 11:22:06 +1100

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


-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: INDESIGN: Duplicating Char Style from One Doc to Another (From: Rick Gordon <email@hidden>)

  • Prev by Date: Re: INDESIGN: Duplicating Char Style from One Doc to Another
  • Next by Date: New to Applescript
  • Previous by thread: Re: INDESIGN: Duplicating Char Style from One Doc to Another
  • Next by thread: Re: AppleScript-Users Digest, Vol 10, Issue 121
  • Index(es):
    • Date
    • Thread