Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Trim function in Word (Word xp)

    I have a large fixed width ASCII file that I'm working with in Word. I need to trim the spaces off a variable such as

    strPlan = " PLAN: 705 "

    in excel i would use TRIM(strPlan), and i tried it in Word but it didn't work. Is there a way to get rid of the spaces using VBA code? thanks

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Trim function in Word (Word xp)

    Trim should work the same in Word as in Excel

    string = Trim(string)

    What happens when 'it doesn't work'? Is there a possibility that what looks like spaces are some other character?
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Trim function in Word (Word xp)

    Ayup!

    But use Trim$, it's faster.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Trim function in Word (Word xp)

    It might be faster if there will always be a string in the value passed to Trim$, but if you happen to pass it a null, you take a detour through the error handing.
    Charlotte

Posting Permissions

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