Results 1 to 5 of 5

Thread: Want to eliminate symbols from the content of the word

  1. #1

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Want to eliminate symbols from the content of the word

    Hi all,

    I am just creating some sort of macros in MS Word. In that macro, I want to eliminate all the characters except "a to z", "A to Z" and "0 to 9" (i.e., all characters and Digits).

    For example, the text in Word Document,

    "I am currently reading "$56 in an hour" Book and, What? etc. and I will work on Mike's Project tomorrow. and Some more text here"

    Clearly, I want to ignore all the symbols, full stop, colon, semicolon, quotation marks, space, non breaking space, not printable characters, etc. If I run a code it should change the above sentence as:

    Iamcurrentlyreading56inanhourBookandWhatelseetcandIwillworkonMksProjecttomorrowandSomemoretexthere

    Please help me!

    Thanks,

    CS.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Want to eliminate symbols from the content of the word

    test this, for some reason it left a few spaces in the text, but if i ran it again they all went

    VB Code:
    1. Selection.WholeStory
    2.  
    3. For i = Selection.Characters.Count To 1 Step -1
    4. char = Selection.Characters(i)
    5.  
    6. Select Case char
    7.     Case "A" To "Z", "a" To "z", "0" To "9"
    8.     Case Else
    9.         Selection.Characters(i).Delete
    10.  
    11. End Select
    12. Next

    pete

  3. #3

    Thread Starter
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Want to eliminate symbols from the content of the word

    I know this way. We can use For.....Loop, or Do...While loop. Buy, the content of the document is huge then, this will take too much of time to process. Is there any other options available?

    Is there any options, in Find & Replace to Find all symbols and delete it?

    Thanks,

    CS.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Want to eliminate symbols from the content of the word

    feel free, even if you use a replace function, while it seems to be less code to run, does not neccessarily work any faster, the only way to find out is speed tests

    maybe it is possible in an xml schema, but i wouldn't be sure

    i don't know of any way to use the LIKE operator with NOT to replace all characters that didn't match, or even if LIKE would work with Replace

    pete

  5. #5
    Member Alankar's Avatar
    Join Date
    Jun 2005
    Location
    Ghaziabad, India
    Posts
    40

    Wink Re: Want to eliminate symbols from the content of the word

    Yes,

    You can do this, By using following in the find what box -

    [!Aa0-zZ9]

    Replace it with "" (Nothing) then you would get the same results as you want.

    Regards,

    Alankar

    PS- Don't forget to click the Use Wildcards box at the bottom.
    The rest of mind is not in rest, It rests in rest.

Posting Permissions

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



Click Here to Expand Forum to Full Width