aspnetvbnetnerd
Programmer
Does anyone know if FreeFile work with VbScript Or is it me?
Code:
'Objects
Dim ObjFso
Dim ObjExel
Dim parFilesFromFolderPath
Dim File
Dim Line
Dim TextStream
Dim Arr
Dim RowIndex
Dim FileName
Dim oBook
Dim FileNr
Dim sFileInput
RowIndex = 1
'Set objects
Set ObjFso = CreateObject("Scripting.FileSystemObject")
Set ObjExel = CreateObject("Excel.Application")
Set oBook = ObjExel.Workbooks.Add
ObjExel.Visible = vbTrue
'Set folder path
Set parFilesFromFolderPath = ObjFso.GetFolder("D:\temp\")
'Loop all folders
For Each File In parFilesFromFolderPath.Files
' Delete all files exept the latest
If UCase(ObjFso.GetExtensionName(File.Name)) = "TXT" Then
'msgbox File.Path
FileNr = FreeFile
[COLOR=red][b]Open File.Path For Input As #FileNr[/b] <-- Error[/color]
While Not EOF(FileNr)
Line Input #FileNr, Line
Arr = Split(Line, ";")
'Split and add it to and array
Arr = Split(Line, ";")
Wend
Close #FileNr
'Set the FileName
FileName = (Left(File.Path, Len(File.Path) - 3) & "xlsx")
'Save the file
'oBook.SaveAs (FileName)
'Exit excel and clear from memory
'ObjExel.Quit
End If
Next
Set ObjExel = Nothing