Hiya Folks
Im new to using .vbs files and scripting like this so you may need to break it down a bit for me. normally using Visual basic express - and only been dong this for about 1 year no schooling.
In my file open section ive used *.txt but when i use it on the delete section its deletes all my files in that area which isnt what i want sort of.
What i need the vbs file to do is open the first file it finds, save it to excel, then delete the used file, so that when it runs the second time it uses the second file.
Probably slighty messy version but works for me at the minute.
Struggling on getting a loop together as well so that when the program runs, its will work though all the files in the folder till there all transfered then deleted.
*Edited section*
First coloumn contains the title of the generated textfile but without the extension .txt bit.
bit about the program.
1st excel file open which is going to be the report (no headers used yet) excel column Z row 1 has a countIf(A:A) to count how many rows used.
second excel section is the .txt file that is being transfed to the reports excel.
heres the code:
'open excel Dim oXl, strFile2Open', strFile2Save 'open and load all row data into Reports strFile2Open = "C:\Documents and Settings\liam\Desktop\Freshly sorted\Reports\Web 1.xls" Set oXl = WScript.CreateObject("Excel.Application") 'Make Excel visible. oXl.Visible = True oxl.Workbooks.OpenText strFile2Open Dim oXl2, strFile3Open', strFile3Save, strfile3DeleteFile 'open textfile to be transfered into Excel strFile3Open = "C:\Documents and Settings\liam\Desktop\Freshly sorted\Customer Service files\*.txt" Set oXl2 = WScript.CreateObject("Excel.Application") 'Make Excel visible. oXl2.Visible = True oxl2.Workbooks.OpenText strFile3Open 'Row count from 1st excel file oxl.Cells(oxl.cells(1,26).value+1, 1).Value = oxl2.Cells(1,1) oxl.Cells(oxl.cells(1,26).value, 2).Value = oxl2.Cells(2,1) oxl.Cells(oxl.cells(1,26).value, 3).Value = oxl2.Cells(3,1) oxl.Cells(oxl.cells(1,26).value, 4).Value = oxl2.Cells(4,1) oxl.Cells(oxl.cells(1,26).value, 5).Value = oxl2.Cells(5,1) oxl.Cells(oxl.cells(1,26).value, 6).Value = oxl2.Cells(6,1) 'This should contain the file name without the file extension fs = oxl.Cells(oxl.cells(1,26).value, 1).Value oxl.ActiveWorkBook.Close True oxl.Quit() oxl.displayalerts = False oxl2.ActiveWorkBook.Close False oxl2.Quit() oxl2.displayalerts = True 'delete the textfile once imported dim filesys Set objFSO = CreateObject("Scripting.FileSystemObject") 'fs should be the filename that needs to be deleted. objFSO.DeleteFile("C:\Documents and Settings\liam\Desktop\Freshly sorted\Customer Service files\fs.txt") Thanks In advance.
<message edited by rimlesskid on Monday, March 07, 2011 12:06 AM>