2 Replies Latest reply on Apr 3, 2008 1:39 PM by sstanleyau

    remove a stealth applied character style AppleScript

      I have created a paragraph style, created a text box, inserted a digit, and applied the created paragraph style. When I run the script, a character style is applied to the digits. I need the character style for other purposes. How do either apply "no character style" or create, apply, then remove a character style. Here is my current appleScript:

      tell application "Adobe InDesign CS3"
      activate
      tell document 1
      --set the measurement units, set ruler origin to page rather than spread, and make sure ruler origin is set to corner of page
      set horizontal measurement units of view preferences to picas
      set vertical measurement units of view preferences to picas
      set ruler origin of view preferences to page origin
      set zero point to {0, 0}

      --ask for number of pages in the front matter
      display dialog "How many pages does the front matter have? :" default answer "0"
      set dialogInfo to result
      set selectedButton to button returned of dialogInfo
      get selectedButton
      set frontNum to text returned of dialogInfo

      --ask for number of pages in the book
      display dialog "How many pages does the book have? :" default answer "0"
      set dialogInfo to result
      set selectedButton to button returned of dialogInfo
      get selectedButton
      set totalPages to text returned of dialogInfo

      --set paragraph styles for frontmatter page numbers
      try
      set FrNumStyle to paragraph style "front"
      on error
      set FrNumStyle to make paragraph style
      tell FrNumStyle
      --set font size to 10
      set name to "front"
      set space after to 0.0
      set space before to 0.0
      set left indent to 0.0
      set right indent to 0.0
      end tell
      end try
      --set paragraph styles for bodymatter page numbers
      try
      set NumStyle to paragraph style "page"
      on error
      set NumStyle to make paragraph style
      tell NumStyle
      --set font size to 10
      set name to "page"
      set space after to 0.0
      set space before to 0.0
      set left indent to 0.0
      set right indent to 0.0
      end tell
      end try

      end tell

      --insert text box and page numbers on frontmatter pages
      repeat with DocPage from 1 to frontNum
      tell page DocPage of document 1
      set pageNum to document offset as string
      set pageNumFrame to make text frame with properties {geometric bounds:{"1.3p", "7.8p", "2.4p", "10p"}}
      set contents of pageNumFrame to pageNum
      tell text 1 of parent story of pageNumFrame to recompose
      set applied paragraph style of parent story of pageNumFrame to "front"
      set applied character style of text of parent story of pageNumFrame to "[no character style]"
      end tell
      end repeat

      --insert text box and page number on bodymatter pages
      repeat with DocPage from (frontNum + 1) to totalPages
      tell page DocPage of document 1
      set tempPage to (frontNum)
      set pageNum to (document offset - frontNum)
      set pageNumber to pageNum as string
      --if pageNum is greater than "0" then
      set pageNumFrame to make text frame with properties {geometric bounds:{"1.3p", "7.8p", "2.4p", "10p"}}
      set contents of pageNumFrame to pageNumber
      tell text 1 of parent story of pageNumFrame to recompose
      set applied paragraph style of parent story of pageNumFrame to "page"
      set applied character style of text of parent story of pageNumFrame to "[no character style]"
      end tell
      end repeat
      end tell
        • 1. Re: remove a stealth applied character style AppleScript
          Level 1
          Apparently, the list is not clear on my problem.

          When I apply a new paragraph style to newly created text in a newly
          created text box, an unwanted character style is applied. I have
          tried the following lifted right out of Adobe InDesign CS 3 Scripting
          Guide:

          set myStory to parent story of myTextFrame
          tell character 1 of myStory
          set align to baseline to false
          set applied character style to character style "[None]" of myDocument
          ...

          Here is the relevant part of my script:

          repeat with DocPage from 1 to frontNum
          tell page DocPage of myDocument
          set pageNum to document offset as string
          set pageNumFrame to make text frame with properties {geometric
          bounds:{"1.3p", "7.8p", "2.4p", "10p"}}
          set contents of pageNumFrame to pageNum
          tell every character of the parent story of pageNumFrame
          set applied character style to character style "[None]"
          end tell
          tell paragraph 1 of parent story of pageNumFrame to apply
          paragraph style using FrNumStyle
          end tell
          end repeat



          I get error 30477
          Invalid value for set property 'applied character style'. Expected
          character style or string but received nothing.

          Can anyone point me in the right direction?


          Terry Ofner
          1541 Northbrook Drive
          Indianapolis, IN 46260
          Voice: 317-870-1992
          Fax: 317-870-7101

          tofner@comcast.net




          On Apr 3, 2008, at 10:57 AM, Terry Ofner wrote:
          > A new discussion was started by Terry Ofner in
          >
          > InDesign Scripting --
          > remove a stealth applied character style AppleScript
          >
          > I have created a paragraph style, created a text box, inserted a
          > digit, and applied the created paragraph style. When I run the
          > script, a character style is applied to the digits. I need the
          > character style for other purposes. How do either apply "no
          > character style" or create, apply, then remove a character style.
          > Here is my current appleScript:
          >
          > tell application "Adobe InDesign CS3"
          > activate
          > tell document 1
          > --set the measurement units, set ruler origin to page rather than
          > spread, and make sure ruler origin is set to corner of page
          > set horizontal measurement units of view preferences to picas
          > set vertical measurement units of view preferences to picas
          > set ruler origin of view preferences to page origin
          > set zero point to {0, 0}
          >
          > --ask for number of pages in the front matter
          > display dialog "How many pages does the front matter have? :"
          > default answer "0"
          > set dialogInfo to result
          > set selectedButton to button returned of dialogInfo
          > get selectedButton
          > set frontNum to text returned of dialogInfo
          >
          > --ask for number of pages in the book
          > display dialog "How many pages does the book have? :" default
          > answer "0"
          > set dialogInfo to result
          > set selectedButton to button returned of dialogInfo
          > get selectedButton
          > set totalPages to text returned of dialogInfo
          >
          > --set paragraph styles for frontmatter page numbers
          > try
          > set FrNumStyle to paragraph style "front"
          > on error
          > set FrNumStyle to make paragraph style
          > tell FrNumStyle
          > --set font size to 10
          > set name to "front"
          > set space after to 0.0
          > set space before to 0.0
          > set left indent to 0.0
          > set right indent to 0.0
          > end tell
          > end try
          > --set paragraph styles for bodymatter page numbers
          > try
          > set NumStyle to paragraph style "page"
          > on error
          > set NumStyle to make paragraph style
          > tell NumStyle
          > --set font size to 10
          > set name to "page"
          > set space after to 0.0
          > set space before to 0.0
          > set left indent to 0.0
          > set right indent to 0.0
          > end tell
          > end try
          >
          > end tell
          >
          > --insert text box and page numbers on frontmatter pages
          > repeat with DocPage from 1 to frontNum
          > tell page DocPage of document 1
          > set pageNum to document offset as string
          > set pageNumFrame to make text frame with properties {geometric
          > bounds:{"1.3p", "7.8p", "2.4p", "10p"}}
          > set contents of pageNumFrame to pageNum
          > tell text 1 of parent story of pageNumFrame to recompose
          > set applied paragraph style of parent story of pageNumFrame to "front"
          > set applied character style of text of parent story of pageNumFrame
          > to "[no character style]"
          > end tell
          > end repeat
          >
          > --insert text box and page number on bodymatter pages
          > repeat with DocPage from (frontNum + 1) to totalPages
          > tell page DocPage of document 1
          > set tempPage to (frontNum)
          > set pageNum to (document offset - frontNum)
          > set pageNumber to pageNum as string
          > --if pageNum is greater than "0" then
          > set pageNumFrame to make text frame with properties {geometric
          > bounds:{"1.3p", "7.8p", "2.4p", "10p"}}
          > set contents of pageNumFrame to pageNumber
          > tell text 1 of parent story of pageNumFrame to recompose
          > set applied paragraph style of parent story of pageNumFrame to "page"
          > set applied character style of text of parent story of pageNumFrame
          > to "[no character style]"
          > end tell
          > end repeat
          > end tell
          >
          > View/reply at remove a stealth applied character style AppleScript
          > Replies by email are OK.
          > Use the unsubscribe form to cancel your email subscription.
          >
          • 2. Re: remove a stealth applied character style AppleScript
            sstanleyau Level 4
            On 4/4/08 3:35 AM, "Terry Ofner" <member@adobeforums.com> wrote:<br /><br />> An unwanted character style is applied.<br /><br />What character style?<br /><br />> tell every character of the parent story of pageNumFrame<br />> set applied character style to character style "[None]"<br /><br />Don't tell every character; just tell the story.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>