Consulting

Results 1 to 6 of 6

Thread: Find a colon and insert a space 2 characters to the right

  1. #1

    Find a colon and insert a space 2 characters to the right

    In the body of a 2010 Word document, I am selecting a block of one-line paragraphs such as this.

    1:09The paragraph always starts with a time value
    1:18followed by a short text string. Ignore any other colons.
    1:25Insert a space two characters to the right of the colon
    12:30Thanks for your help!

    I want to search for a colon in the within the first 4 characters of the paragraph, and when found, insert a space two characters to the right of the colon. The result should look like this.

    1:09 The paragraph always starts with a time value
    1:18 followed by a short text string. Ignore any other colons.
    1:25 Insert a space two characters to the right of the colon
    12:30 Thanks for your help!


    Thanks!!

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    You could do this with an ordinary Find/Replace, where:
    Find = :^#^#
    Replace = ^&^32
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Thank you so much! That was a simple and elegant solution! I was not familiar with ^&

    Many blessings!

    Brian

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    FWIW, ^32 is just a space character - which you could have used instead of ^32. Alternatively, if you wanted a non-breaking space, you could use ^s or ^0160 instead of ^32.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    I knew that 32 was the ascii code for a space. I didn't know what ^& represented, but I assume that it must be the results of the Find.

    Thanks again!

    Brian

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Yes, ^& represents the 'Find' text. You will see a bunch of different 'special' expressions if you click on the Find/Replace dialogue's 'More' button, then 'Special'. The Find and Replace each has its own set, which varies according to whether or not you're using wildcards.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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