I have some code I'm messin' with. I want to manipulate a text file before it is imported, this way I can minimize the amount of queries in my d/base....
I'm tryin' to insert the days date in each line of a text file. The problem I'm having is that the newly inserted text overwrites the existing text, insteading of moving it over per say - so that columns all stay in alignment. The text file is "fix width".
I sure hope this makes sense..!!
Any suggestion or examples..??
Thanks in advance..!!
Below is what I am working with..
jcw5107
Sub AssignedTaskReformat5()
DoCmd.Hourglass True
Dim db As DAO.Database
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
Dim strNewfile As String
strImportFile = "D:\UPSDATA\SchedWorkWANMain.txt"
strNewfile = "D:\UPSDATA\SchedWorkWANMstr.txt"
Open strImportFile For Input As #1
Open strNewfile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 2) = "E " _
Or Left(strLine, 2) = "S " _
Or Left(strLine, 2) = "P " Then
Mid(strLine, 350, 14) = Now()
End If
Print #2, strLine
Loop
Close #1
Close #2
End Sub
I'm tryin' to insert the days date in each line of a text file. The problem I'm having is that the newly inserted text overwrites the existing text, insteading of moving it over per say - so that columns all stay in alignment. The text file is "fix width".
I sure hope this makes sense..!!
Any suggestion or examples..??
Thanks in advance..!!
Below is what I am working with..
jcw5107
Sub AssignedTaskReformat5()
DoCmd.Hourglass True
Dim db As DAO.Database
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
Dim strNewfile As String
strImportFile = "D:\UPSDATA\SchedWorkWANMain.txt"
strNewfile = "D:\UPSDATA\SchedWorkWANMstr.txt"
Open strImportFile For Input As #1
Open strNewfile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 2) = "E " _
Or Left(strLine, 2) = "S " _
Or Left(strLine, 2) = "P " Then
Mid(strLine, 350, 14) = Now()
End If
Print #2, strLine
Loop
Close #1
Close #2
End Sub