Limit Number of Characters per Row in .txt File

Hello,
There is a group at my company that needs to submit their documents to another company in ASCII format but for some reason this company won't let them use the program that will format all of this for them.
I was wondering if there was any way to write a script (ideally vbscript) to limit the number of characters per line in a notepad document to 98? I've been looking everywhere and I can't seem to find anything.

Thank you
LVL 1
Brent387Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
what should happen when there are > 98 characters in the line?
wrap?  or cut?
0
Brent387Author Commented:
wrap
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
here we go
strFile = "C:\source_file.txt"
strDest = "C:\dest_file.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strFile)

If objFile.Size > 0 Then
    Set objReadFile = objFSO.OpenTextFile(strFile, 1)
    Set objWriteFile = objFSO.OpenTextFile(strDest, ForOutPut, True)

    while not objReadFile.AtEndOfStream
      strLine = objReadFile.ReadLine
      while strLine <> ""
         objWriteFile.WriteLine(left(strLine, 98))
         strLine = mid(strLine, 99)
      Wend

    Wend
    objReadFile.Close
    objWriteFile.Close
Else
    Wscript.Echo "The source file does not exist."
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

rlandquistCommented:
I think line 9 should be:
Set objWriteFile = objFSO.CreateTextFile(strDest,  True)
unless you are pre creating the destination file before running the script.
0
Brent387Author Commented:
Line 9 was off but it was corrected.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry for that, copy/pasted the line and forgot to change the method name ...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.