Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-15-2014, 12:54 AM
ksridh ksridh is offline first character NOT Alpha numeric or Tilde (~) delete. Windows 7 32bit first character NOT Alpha numeric or Tilde (~) delete. Office 2010 32bit
Novice
first character NOT Alpha numeric or Tilde (~) delete.
 
Join Date: Mar 2014
Posts: 3
ksridh is on a distinguished road
Default first character NOT Alpha numeric or Tilde (~) delete.

Hi,

I have the GRE words list that I have copied from a PDF file to Word. First character of each line in this Word file is NOT an alphanumeric one or Tilde (~). If they are, I want to move to next line, otherwise delete that character and the space joining it. I need to do this to all lines.

Here is my Code and this works fine only for first few lines and goes for a toss:
--------------------------------------
Code:
Sub FormatData()
     'Declare variables
    Dim numOfLines As Integer
    Dim ascVal As Integer
    Dim doc As Document
    Set doc = ActiveDocument
     'Count the number of non blank lines In current document
    numOfLines = ActiveDocument.BuiltInDocumentProperties("NUMBER OF LINES")
     'Move to start of document
    Selection.HomeKey Unit:=wdStory
     'ascVal = (Asc(doc.Sentences(58).Characters(1).Text))
     'MsgBox (ascVal)
    For x = 1 To numOfLines
         'MsgBox (x)
        ascVal = (Asc(doc.Sentences(x).Characters(1).Text))
         'MsgBox (ascVal)
        Selection.HomeKey Unit:=wdLine
        If Not (((ascVal >= 65 And ascVal <= 90) Or (ascVal >= 97 And ascVal <= 122) Or (ascVal >= 48 And ascVal <= 57) Or (ascVal = 126))) Then
             'MsgBox  (doc.Sentences(x).Characters(1).Text)
            Selection.Delete Unit:=wdCharacter, Count:=2
            Selection.MoveDown Unit:=wdLine, Count:=1
            Selection.HomeKey Unit:=wdLine
             'MsgBox (x)
        Else
            Selection.MoveDown Unit:=wdLine, Count:=1
            Selection.HomeKey Unit:=wdLine
        End If
         'Selection.HomeKey Unit:=wdLine
    Next
End Sub
------------------------------------



Thanks.....Karthik....

Last edited by macropod; 03-15-2014 at 05:01 AM. Reason: Added code tags & formatting
Reply With Quote
 

Tags
delete first character



Similar Threads
Thread Thread Starter Forum Replies Last Post
first character NOT Alpha numeric or Tilde (~) delete. How to do an alpha numeric Sort By? Opul3nce Excel 1 10-15-2012 11:11 PM
first character NOT Alpha numeric or Tilde (~) delete. Unique 3 char Alpha Numberic column mauricioaglr Excel 7 03-09-2012 06:45 PM
first character NOT Alpha numeric or Tilde (~) delete. Word 2007 TOC Section Number w/Alpha Prefix? Gwen Butler Office 2 09-29-2011 06:10 AM
first character NOT Alpha numeric or Tilde (~) delete. Place pages in alpha order. Wskip49 Word 5 08-28-2011 07:54 PM
first character NOT Alpha numeric or Tilde (~) delete. [How To] Generate Alpha Numeric Values in Excel 2010 stnicholas81 Excel 1 07-25-2011 01:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft