4 Replies Latest reply on Mar 25, 2008 5:24 PM by (Robert_Tkaczyk)

    How to apply Paragraph Style to all story?

    Level 1
      Give a hint, pls.
      To do that I tryed (as a attempts to understand methodology):

      Set MyObj = MyInd.ActiveDocument
      Set myInsertionPoint = MyInd.Selection.Item(1)
      Set myTextFrame = myInsertionPoint.ParentTextFrames
      Set myTextToStyle = myInsertionPoint.Texts.Item(1)

      myTextToStyle.ApplyParagraphStyle (MyObj.ParagraphStyle = "Body")
      'doesnt support property or method

      Call myTextFrame.Texts.ApplyParagraphStyle("Body", True)
      'doesnt support property or method

      myTextFrame.ParentStory.Paragraphs.Item(1).AppliedParagraphStyle = "Body"
      'doesnt support property or method

      Call myInsertionPoint.Texts.Item(1).ApplyParagraphStyle(ParagraphStyle = "Body
      'invalid value for parametr "Using" of Event "ApplyParagraphStyle"...

      and so on.

      Can't understand how to write exactly. I.e. i need to apply para style to all text in story.

      In Pagemaker it was simple:
      SelectAll
      Style "Body" - that's it.

      Thanks.
        • 1. Re: How to apply Paragraph Style to all story?
          Level 1
          Hi Dmitry1776,

          Try something like this:

          Set myTextToStyle = myInsertionPoint.ParentStory.Texts.Item(1)
          myTextToStyle.ApplyParagraphStyle MyObj.ParagraphStyles.Item("Body")

          Thanks,

          Ole
          • 2. Re: How to apply Paragraph Style to all story?
            Level 1
            Great, it works!

            Many thanks, Olav.
            • 3. Re: How to apply Paragraph Style to all story?
              Level 1
              Set MyObj = MyInd.ActiveDocument
              ' OK

              Set myInsertionPoint = MyInd.Selection.Item(1)
              ' will set InsertionPoint only if you have cursor in text - nothing selected

              Set myTextFrame = myInsertionPoint.ParentTextFrames
              ' (*) you get reference to collection of ParentTextFrames
              ' you should write:
              Set myTextFrame = myInsertionPoint.ParentTextFrames.Item(1)

              Set myTextToStyle = myInsertionPoint.Texts.Item(1)
              ' but this will get you nothing
              ' you should write:
              Set myTextToStyle = myInsertionPoint.ParentStory.Texts.Item(1)
              ' like in Olav's example

              myTextToStyle.ApplyParagraphStyle (MyObj.ParagraphStyle = "Body")
              'doesnt support property or method
              ' because you can't write like this ;)
              ' you should write:
              myTextToStyle.ApplyParagraphStyle(MyObj.ParagraphStyles.item("Body"))
              ' or
              myTextToStyle.AppliedParagraphStyle=MyObj.ParagraphStyles.item("Body")

              Call myTextFrame.Texts.ApplyParagraphStyle("Body", True)
              'doesnt support property or method
              ' because you need to refer to item in collection
              Call myTextFrame.Texts.Item(1).ApplyParagraphStyle("Body", True)
              ' but this will apply ParaStyle only to Text in TextFrame - not to whole story

              myTextFrame.ParentStory.Paragraphs.Item(1).AppliedParagraphStyle = "Body"
              'doesnt support property or method
              ' because myTextFrame refer to collection - check 3rd SET (*)
              ' and will work if you use my version of SET command
              ' but this will apply ParaStyle only to first Paragraph in Story

              Call myInsertionPoint.Texts.Item(1).ApplyParagraphStyle(ParagraphStyle = "Body
              'invalid value for parametr "Using" of Event "ApplyParagraphStyle"...
              ' because this is wrong - should be:
              Call myInsertionPoint.Texts.Item(1).ApplyParagraphStyle(MyObj.ParagraphStyles.item("Body"))
              ' but this will apply ParaStyle only to parent Paragraph

              robin

              --
              www.adobescripts.com
              • 4. Re: How to apply Paragraph Style to all story?
                Level 1
                errata :)

                in this part:

                myTextToStyle.ApplyParagraphStyle (MyObj.ParagraphStyle = "Body")
                'doesnt support property or method
                ' because you can't write like this ;)
                ' you should write:
                myTextToStyle.ApplyParagraphStyle(MyObj.ParagraphStyles.item("Body"))
                ' or
                myTextToStyle.AppliedParagraphStyle=MyObj.ParagraphStyles.item("Body")

                should be:

                myTextToStyle.ApplyParagraphStyle(MyDoc.ParagraphStyles.item("Body"))
                ' or
                myTextToStyle.AppliedParagraphStyle=MyDoc.ParagraphStyles.item("Body")

                where myDoc is reference to document you process

                robin

                --
                www.adobescripts.com