![]() |
#1
|
|||
|
|||
![]()
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 |
Tags |
delete first character |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Opul3nce | Excel | 1 | 10-15-2012 11:11 PM |
![]() |
mauricioaglr | Excel | 7 | 03-09-2012 06:45 PM |
![]() |
Gwen Butler | Office | 2 | 09-29-2011 06:10 AM |
![]() |
Wskip49 | Word | 5 | 08-28-2011 07:54 PM |
![]() |
stnicholas81 | Excel | 1 | 07-25-2011 01:31 AM |