Any idea why I keep getting a Run -time error 62 Input past end of file error with the following code when using the Input function. The help function tells me the file is in binary and I should use either LOF or Seek however neither seems to work. This code worked fine until a recent Windows and Microsoft update to my computer.
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFilePicker)
With fldr
.Filters.Clear
.Filters.Add "All files", "*.*"
.Title = "Select a CFG File to Convert fromatting from R2013 to 1991."
.AllowMultiSelect = False
.InitialFileName = ActiveWorkbook.Path 'Application.DefaultFilePath
If .Show <> -1 Then Exit Sub
sItem = .SelectedItems(1)
End With
set fldr = Nothing
Open sItem For Input As #1
dataArray = Split(Input(LOF(1), #1), vbLf)
Close #1
If Len(dataArray(2)) - Len(Replace(dataArray(2), ",", "")) = 9 Then
MsgBox "It appears the comtrade file format already conforms to the 1991 standard version." & vbNewLine & "" & vbNewLine & "Conversion was Aborted."
Exit Sub
End If
I'm trying to count the number of commas in line 3 of the selected file.