Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    replace text with paragraph marker (ALL)

    Is it possible to replace text with paragraph markers? For example,

    paraRead = Replace(paraRead, "xyzxyz", "^p") ' this doesn't seem to work

    or

    do I assing the paragraph text to a range and then use the Find/Replace method to do this?
    Thanks.
    Robie

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: replace text with paragraph marker (ALL)

    Instead of using "^p", try using the Visual basic constant vbCrLf, so that your command is
    <code>paraRead = Replace(paraRead, "xyzxyz", vbCrLf) </code>

    StuartR

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: replace text with paragraph marker (ALL)

    Codes such as ^p can be used in the Edit | Find and Edit | Replace dialogs, and in their VBA equivalent, the Text and Replacement.Text properties of the Find object.

    In your code, however, Replace is a standard VBA function (it's also available in VBA for Excel, PowerPoint, Outlook etc.), it's not specific to Word. So it doesn't "know" Word-specific codes such as ^p.

    Microsoft Word uses vbCr = Chr(13) as paragraph end character, so you can use

    paraRead = Replace(paraRead, "xyzxyz", vbCr)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •