Okay, I have some some text files that I'm trying to edit and then string together. I've altered my code a little and was trying to get some additional Ideas. Here is what my code looks like now:
The data that I'm supposed to be getting back should look like this:
ST TRANSACTION SET HEADER
ST*837*0021~
BHT BEGINNING OF HIERARCHICAL TRANSACTION
BHT*0019*00*0123*19981015*1023*RP~
REF TRANSMISSION TYPE IDENTIFICATION
REF*87*004010X098~
What I'm actually getting back looks like this:
=¥»¡–ï;ä`á—»ÒÝléζ ªûˆ§<ÿùÜ*ÞcHrÎí™î‹>챕ê§þ –ßsðž~
JÌ PK K™p0l¾2 ¯
¶ pmsp5440.clmUT ~
It seems to be the right AMOUNT of data but as you can see it's no good. And it doesn't matter what you put in for the FORMAT argument for the OpenAsTextStream Method. I've tried all the options.
Thanks for any help,
Chris
Code:
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim FileObject
Dim SourceFolder
Dim FileCollection
Dim File
Dim Readfile
Dim ThisTxt
Dim FinalTxt
Dim WriteFile
Dim Filename
Set FileObject = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FileObject.GetFolder("C:\files\")
Set FileCollection = SourceFolder.Files
for each File in FileCollection
'FileName = "C:\files\" & File.Name
Set Readfile = File.OpenAsTextStream(ForReading)
ThisTxt = ReadFile.Readall
Readfile.close
ThisTxt = Replace(ThisTxt, vbCRLF, "")
ThisTxt = replace(ThisTxt, "~", "~" & vbCRLF)
FinalTxt = FinalTxt & vbCRLF & ThisTxt
Next
FileObject.CreateTextFile("c:\pmsp0000.txt")
Set FileName = FileObject.GetFile("c:\pmsp0000.txt")
Set WriteFile = FileName.OpenAsTextStream(ForWriting)
WriteFile.Write(FinalTxt)
WriteFile.Close
Msgbox "Done adding carriage returns and combining files!"
The data that I'm supposed to be getting back should look like this:
ST TRANSACTION SET HEADER
ST*837*0021~
BHT BEGINNING OF HIERARCHICAL TRANSACTION
BHT*0019*00*0123*19981015*1023*RP~
REF TRANSMISSION TYPE IDENTIFICATION
REF*87*004010X098~
What I'm actually getting back looks like this:
=¥»¡–ï;ä`á—»ÒÝléζ ªûˆ§<ÿùÜ*ÞcHrÎí™î‹>챕ê§þ –ßsðž~
JÌ PK K™p0l¾2 ¯
¶ pmsp5440.clmUT ~
It seems to be the right AMOUNT of data but as you can see it's no good. And it doesn't matter what you put in for the FORMAT argument for the OpenAsTextStream Method. I've tried all the options.
Thanks for any help,
Chris