How to automatically copy text out of excel files -
i have 250 microsoft excel (.xls) files, in folder. need following:
for each file: open file switch specific tab in file extract text rows 15-100 on tab save text in text file somewhere
i assume can automated somehow, have no idea how. start looking figure out how this? don't want open 250 excel files , copy text out hand, take hours. :(
since have excel, can create excel macro in separate worksheet this; make sure worksheet outside of directory parsing. you'll need add reference filesystemobject, should found in c:\windows\system32\scrrun.dll.
option explicit sub extractdata() dim fso new filesystemobject dim ofile file dim ofolder folder dim sfileoutput string dim fnum dim excelfile excel.workbook dim excelworksheet excel.worksheet dim integer sfileoutput = "c:\foldertoscan\exceloutput.txt" set ofolder = fso.getfolder("c:\foldertoscan") each ofile in ofolder.files if right(ofile.name, 3) = "xls" fnum = freefile() open sfileoutput append fnum set excelfile = workbooks.open(ofile.path) set excelworksheet = excelfile.sheets(1) 'or: ' set excelworksheet = excelfile.sheets("name of sheet") = 15 100 write #fnum, excelworksheet.cells(i, 1) next close #fnum excelfile.close set excelfile = nothing end if next end sub
Comments
Post a Comment