cbones
asked on
Script to extract the first 30 characters of each line from a file
Hello,
I have a word document that is 145 pages. I only need the first 30 characters of each line. Is there any way to have a script scan the file and either extract the first 30 characters of each line and create a new file or delete the rest from each line?
Thank you
I have a word document that is 145 pages. I only need the first 30 characters of each line. Is there any way to have a script scan the file and either extract the first 30 characters of each line and create a new file or delete the rest from each line?
Thank you
I have a word document that is 145 pages. I only need the first 30 characters of each line.
Define "line". There is no such object in Word.
Indeed, since different print drivers can render printed text differently, the whole concept of a "line" of text does not make much sense.
Did you perhaps mean "I only need the first 30 characters of each paragraph"?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am not able to get this script to work. I will try it again.
What happens when you try it?
ASKER
I recieve
line 2
char 8
expected end of statement
line 2
char 8
expected end of statement
Please attach the file that you are trying to read.
Dim FF As Integer
Dim FF2 As Integer
Dim strLine As String
FF = FreeFile
Open "C:\temp\test.doc" For Input As #FF
FF2 = FreeFile
Open "C:\temp\temp.doc" For Output As #FF2
Do While Not EOF(FF)
Line Input #FF, strLine
If Len(strLine) > 29 Then
strLine = Left$(30, strLine)
End If
Print #FF2, strLine
Loop
Close