I created a form and added a button.
The code if for the click event of the button. (I threw this together - seems to work)
Code:
Private Sub cmdParseFile_Click()
'*******************************
' requires a reference set to Microsoft Office xx.0 Object Library
'*******************************
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, MyFile
Dim fDialog As Object
Dim TextLine As String
Dim FileName As String
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "Select a File To Copy"
.Filters.Clear
.Filters.Add "Text", "*.txt"
.Filters.Add "Text", "*.csv"
.InitialFileName = Application.CurrentProject.Path
.Show
If .SelectedItems.Count = 0 Then
MsgBox "No file selected."
Else
FileName = fDialog.SelectedItems(1)
End If
End With
Set fso = CreateObject("Scripting.FileSystemObject")
' Open the file for input.
Set MyFile = fso.OpenTextFile(FileName, ForReading)
' Read from the file
Do While MyFile.AtEndOfStream <> True
TextLine = MyFile.ReadLine
'------------------------------------
'your code to parse the data goes here
Debug.Print TextLine
'------------------------------------
Loop
MyFile.Close
Set MyFile = Nothing
Set fDialog = Nothing
MsgBox "Done"
End Sub
Don't know what you want to do with the data, soooo.........
Have fun