none
Vb Script AScii RRS feed

  • Question

  • HI All I Have 2 Columns 

    1. Customer

    2. City 

    I need to  Trim leading/Trailing Spaces,  Remove  (~ ` ! # $ % @ ^ ' " < > | \ chr(10) & chr(13)) , Keep it in single quotes,Convert to upper case, Remove dashes. For the Above two columns.

     

    Any Help. 

    • Moved by Cindy Meister MVPModerator Friday, October 21, 2011 9:13 AM not using VSTO technology (From:Visual Studio Tools for Office)
    Thursday, October 20, 2011 4:44 PM

Answers

  • There’s a couple of ways to do this. One using ASCII codes.

                Dim chars As Word.Characters

                Dim rng as Word.Range

                chars = rng.Characters

                If Asc(chars.First.Text) = 12 Then rng.Characters.First.Delete() 'page break

                If Asc(chars.Last.Text) = 12 Then rng.Characters.Last.Delete() 'page break

    Another is to use the TrimEnd or TrimStart commands.

               tName = tName.TrimEnd(" ", ",")

    This example removes spaces and commas.  The nice part about this last method is that you can list the full string of characters that you want trimmed and it will remove any it finds.

    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com
    Friday, October 21, 2011 2:43 AM