Okay, I've passed hurdle 1 with my file renaming problem. Now that I've renamed the file I would like to parse in the date. I'm getting a file not found on line 15.
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim FileObject
Dim SourceFolder
Dim FileCollection
Dim File
Dim Readfile
Set FileObject = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FileObject.GetFolder("C:\files\")
Set FileCollection = SourceFolder.Files
for each File in FileCollection
Set ReadFile = FileObject.OpenTextFile(File.Name, ForReading)
thisTxt = ReadFile.ReadAll
Readfile.close
thisTxt = Replace(thisTxt, vbCRLF, "")
thistxt = replace(thistxt, "~", "~" & vbCRLF)
finaltxt = thistxt & vbCRLF & thistxt
Next
set WriteFile = FileObject.CreateTextFile("c:\pmsp0000.txt", ForWriting, false)
WriteFile.Write(finaltxt)
WriteFile.Close
Msgbox "Done removing carriage returns and parsing data!"
Any ideas?
Thanks,
Chris
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim FileObject
Dim SourceFolder
Dim FileCollection
Dim File
Dim Readfile
Set FileObject = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FileObject.GetFolder("C:\files\")
Set FileCollection = SourceFolder.Files
for each File in FileCollection
Set ReadFile = FileObject.OpenTextFile(File.Name, ForReading)
thisTxt = ReadFile.ReadAll
Readfile.close
thisTxt = Replace(thisTxt, vbCRLF, "")
thistxt = replace(thistxt, "~", "~" & vbCRLF)
finaltxt = thistxt & vbCRLF & thistxt
Next
set WriteFile = FileObject.CreateTextFile("c:\pmsp0000.txt", ForWriting, false)
WriteFile.Write(finaltxt)
WriteFile.Close
Msgbox "Done removing carriage returns and parsing data!"
Any ideas?
Thanks,
Chris