Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Remove applied styles with AppleScript

New Here ,
Jun 05, 2012 Jun 05, 2012

In QuarkXPress is was able to remove styles with:

set style sheet of paragraphs of story 1 of current box to null

When I try something similar in InDesign, using:

set applied character style of characters of parent story of myFrame to "[None]"

I get an error saying that "Adobe InDesign CS5.5 got an error: Invalid value for set propery 'applied character style'. Expected character style or string, but received "[None]".

"[None]" is the name of a Character Style Sheet, but for some reason it looks like InDesign doesn't recognize it as such. Does anyone know how to remove the style sheets from placed text?

TOPICS
Scripting
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 05, 2012 Jun 05, 2012

You need to get the character style [None] of the parent document that contains the story.

Try

set applied character style of parent story of myFrame to character style "[None]" of parent of parent story of myFrame

Translate
People's Champ ,
Jun 05, 2012 Jun 05, 2012

Hi,

This kind of stuff always pissed me off. InDesign expected a String. Guess what ? I gave you a String !!!

Anyway, the None character style is always in index 1 ( 0 in js ) so you may use this as a workaround :

tell application "Adobe InDesign CS5.5"

          set find text preferences to nothing

          set change text preferences to nothing

          set find what of find text preferences to "~"

          set change to of change text preferences to " "

          tell active document

 

                    set myFrame to text frame 2 --use your own reference

  name of applied character style of parent story of myFrame

                    set applied character style of parent story of myFrame to character style 1 -- character style 1 would always point to None.

 

          end tell

end tell

Hope it helps,

Loic

http://www.loicaigon.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2012 Jun 05, 2012

That's exactly how I've been feeling – pissed off! 

Thanks for the insight on indexes but now I'm getting an error saying that "object is from a different document or workspace" ...

Here's a block of code from the script:

if content type of myFrame is text type then

     set x to 1

     set paraCount to count of paragraphs of parent story of myFrame

     set applied character style of parent story of myFrame to character style 1

     set applied paragraph style of every paragraph of parent story of myFrame to "Body text rag right"

     repeat until x > paraCount

          set wordCount to count words of paragraph x of parent story of myFrame

          if wordCount < 3 then

               if wordCount = 0 then

                    delete paragraph x of parent story of myFrame

                    set paraCount to paraCount - 1

                    set x to x - 1

               else

                    set applied paragraph style of paragraph x of parent story of myFrame to "Subhead"

               end if

          end if

          set x to x + 1

     end repeat

end if

Am I missing something obvious in my syntax?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 05, 2012 Jun 05, 2012

You need to get the character style [None] of the parent document that contains the story.

Try

set applied character style of parent story of myFrame to character style "[None]" of parent of parent story of myFrame

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2012 Jun 06, 2012
LATEST

That did the trick!

Thanx

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines