2 Replies Latest reply on Apr 29, 2008 10:29 PM by (bhu)

    Create new paragraph in a Textframe

      Hello guys:

      Can anyone advise me how to create a new paragraph in a textframe using VBscript? Currently I am using: myTextFrame.Contents = myTextFrame.Contents + vbCr + new_paragraph_text

      But sometimes it is not working properly. is there any method like myTextFrame.createparagraph or mytextframe.paragraphs.createparagraph?

      Thanks a lot

        • 1. Re: Create new paragraph in a Textframe
          Level 1
          The problem with your code is that Contents is a string, so you are, in effect copying the contents of the frame to a text-only environment and then putting it back -- so it loses its formatting.

          It's also better to work with the parent story of the text frame when dealing with text. Set the contents of the last insertion point of the parent story of the text frame to your new text.

          • 2. Re: Create new paragraph in a Textframe
            Level 1
            Thanks Dave! I've tried mytextframe.ParentStory.InsertionPoints.lastitem, and I think it is a better practice for maintaining Paragraph styles.

            In my project, however, I need to remove all paragraphs and add all new paragraphs with their paragraph styles.

            I have found my real problem: if the textframe is overset, mytextframe.paragraphs.count only return the paragraphs 'visible' in the text frames, those overset paragraph will not be counted. So I got an error because I though it returns all paragraphs in the contents.

            Anyway, thank you very much for your help, really appreciate it!