HelloWorldGuy
MIS
I have a question in reference to thread705-1379089 I'm trying to format one of the ideas there to what I need.
All I want to do is import the column data from a file once a week. the file has 6 lines of headder that will always be deleted then a repeating three lines that look like:
07/03/12 11:47:15 PAGE 1
UNIT ID ITEM NUMBER LOCATION ONHAND
RESTRUCTURED
every page.
My plan is to have one button that creates the filtered file and then one imports it to the table.I already have the import code. Just getting this new file structured. Thanks ahead of time.
Const gstrQUERYNAME As String = "QUERY NAME*" '1st line of head
Const gstrPagLibrary As String = "LIBRARY NAME*" '2nd line of head
Const gstrFILE As String = "FILE *" '3rd line of head
Const gstrILCMU As String = "ILCMUF04 *" '4th line of head
Const gstrDATE As String = "DATE *" 5th line of head
Const gstrDATENUM As String = "07/03/12 *" '1st line of repeating page head
Const gstrUNIT As String = "UNIT ID *" '2nd line of repeating page head
Const gstrRESTRUCTURED As String = " RESTRUCTURED *" '3rd line of repeating page head
Private Sub cmdExecuteCommand_Click()
On Error GoTo Normalize_File_Error
Dim blnCapture As Boolean
Dim lngFileIn As Long, lngFileOut As Long
Dim strData As String
Dim strBuffer As String
lngFileIn = FreeFile
Open "txtFilePath" For Input As #lngFileIn 'other methods allow user to select input file path
lngFileOut = FreeFile
Open "C:\Filtered.txt" For Output As #lngFileOut
Do
Line Input #lngFileIn, strBuffer
If Trim(strBuffer) = "" Then
'Ignore blank line
ElseIf strBuffer Like gstrQUERYNAME Then
blnCapture = False
ElseIf strBuffer Like gstrPagLibrary Then
blnCapture = False
ElseIf strBuffer Like gstrFILE Then
blnCapture = False
ElseIf strBuffer Like gstrILCMU Then
blnCapture = False
ElseIf strBuffer Like gstrDATE Then
blnCapture = False
ElseIf strBuffer Like gstrPagLibrary Then
blnCapture = False
ElseIf strBuffer Like gstrUNIT Then
blnCapture = False
ElseIf strBuffer Like gstrRESTRUCTURED Then
blnCapture = False
ElseIf blnCapture = True Then
'This is where the data is written to the output file
Print #lngFileOut, strData
End If
Loop Until EOF(lngFileIn)
Normalize_File_Exit:
Reset
Exit Sub
Normalize_File_Error:
'Stop
End Sub
All I want to do is import the column data from a file once a week. the file has 6 lines of headder that will always be deleted then a repeating three lines that look like:
07/03/12 11:47:15 PAGE 1
UNIT ID ITEM NUMBER LOCATION ONHAND
RESTRUCTURED
every page.
My plan is to have one button that creates the filtered file and then one imports it to the table.I already have the import code. Just getting this new file structured. Thanks ahead of time.
Const gstrQUERYNAME As String = "QUERY NAME*" '1st line of head
Const gstrPagLibrary As String = "LIBRARY NAME*" '2nd line of head
Const gstrFILE As String = "FILE *" '3rd line of head
Const gstrILCMU As String = "ILCMUF04 *" '4th line of head
Const gstrDATE As String = "DATE *" 5th line of head
Const gstrDATENUM As String = "07/03/12 *" '1st line of repeating page head
Const gstrUNIT As String = "UNIT ID *" '2nd line of repeating page head
Const gstrRESTRUCTURED As String = " RESTRUCTURED *" '3rd line of repeating page head
Private Sub cmdExecuteCommand_Click()
On Error GoTo Normalize_File_Error
Dim blnCapture As Boolean
Dim lngFileIn As Long, lngFileOut As Long
Dim strData As String
Dim strBuffer As String
lngFileIn = FreeFile
Open "txtFilePath" For Input As #lngFileIn 'other methods allow user to select input file path
lngFileOut = FreeFile
Open "C:\Filtered.txt" For Output As #lngFileOut
Do
Line Input #lngFileIn, strBuffer
If Trim(strBuffer) = "" Then
'Ignore blank line
ElseIf strBuffer Like gstrQUERYNAME Then
blnCapture = False
ElseIf strBuffer Like gstrPagLibrary Then
blnCapture = False
ElseIf strBuffer Like gstrFILE Then
blnCapture = False
ElseIf strBuffer Like gstrILCMU Then
blnCapture = False
ElseIf strBuffer Like gstrDATE Then
blnCapture = False
ElseIf strBuffer Like gstrPagLibrary Then
blnCapture = False
ElseIf strBuffer Like gstrUNIT Then
blnCapture = False
ElseIf strBuffer Like gstrRESTRUCTURED Then
blnCapture = False
ElseIf blnCapture = True Then
'This is where the data is written to the output file
Print #lngFileOut, strData
End If
Loop Until EOF(lngFileIn)
Normalize_File_Exit:
Reset
Exit Sub
Normalize_File_Error:
'Stop
End Sub