Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FreeFile

Status
Not open for further replies.

aspnetvbnetnerd

Programmer
Feb 3, 2008
31
SE
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
 
FreeFile, Open, EOF, Line Input# and Close # are VB or VBA, not VBS.
Use the methods of the FileSystemObject.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top