Code:
Sub ReadEntireFileAndPlaceOnWorksheet()
Dim X As Long, FileNum As Long, TotalFile As String, FileName As String, Result As Variant, Lines() As String, rng As Range, i As Long, used As Range, MyFolder As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
MyFolder = .SelectedItems(1)
End With
FileName = Dir(MyFolder & "\*.*")
Do While FileName <> ""
FileName = Dir()
FileNum = FreeFile
Open FileName For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
Lines = Split(TotalFile, vbNewLine)
ReDim Result(1 To UBound(Lines) + 1, 1 To 1)
For X = 1 To UBound(Result)
Result(X, 1) = "'" & Lines(X - 1)
Next
Set used = Sheet1.Cells(1, Sheet1.Columns.Count).End(xlToLeft).Columns
Set rng = used.Offset(0, 1)
rng.Resize(UBound(Result)) = Result
Loop
End Sub
I am trying to find some data in a .dat (binary file). The data should look like this:
Code:
MiHo14.dat
MDF 3.00 TGT 15.0
Time: 06:40:29 PM
Recording Duration: 00:05:02
Database: DB
Experiment: Min Air take
Workspace: MINAIR
Devices: ETKC:1,ETKC:2
Program Description: 0delivupd2
Module_delivupd2
WP: _AWD_5
RP: _AWD
§@
Minimum intake - + revs - Downward gear
Code:
MiHo14.dat
MDF 3.00 TGT 15.0
Time: 06:40:29 PM
Recording Duration: 00:05:02
Database: DB
Experiment: Min Air take
Workspace: MINAIR
Devices: ETKC:1,ETKC:2
Program Description: 0delivupd2
Module_delivupd2
WP: _AWD_5
RP: _AWD
§@
Minimum intake - + revs - Downward gear
Bã|ŽA…@@,s~?
B{À¿…@@@Ý‚Iá
Á<
"@²n¢”N@ÇÿÈÿj
Ð=“SØ•N@ÇÿÈÿj
à¨. —N@ÇÿÈÿj
8²œg˜N@ÇÿÈÿj
0NI,¯™N@ÈÿÈÿj
Ðä$öšN@ÈÿÈÿj
@Q›=œN@ÈÿÈÿj
Пe…N@ÇÿÈÿj
GàÍžN@ÇÿÈÿj"
etc....