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....