vbscript - VB script will not traverse every file in a given folder -


i new vbscript , looking write simple script changes couple cells in few thousand csv files in given folder location. have start, , seems working, except fact when run script (from .bat file calls script) changes , moves 3-8 files @ time. number of files changes random, not changes 5 files or something. not sure wrong in code why not edit , move every single file , couple @ time, here have far, in advance help:

set objfso = wscript.createobject("scripting.filesystemobject") set colfiles = objfso.getfolder("c:\users\xxx\badcsvs").files set xl = createobject("excel.application")  each objfile in colfiles   if lcase(objfso.getextensionname(objfile)) = "csv"     set wb = xl.workbooks.open(objfile)     set sht = xl.activesheet         if(sht.cells(1,11) <> "")         sht.cells(1,8) = sht.cells(1,8) & sht.cells(1,9)         sht.cells(1,9) = sht.cells(1,10)         sht.cells(1,10) = sht.cells(1,11)         sht.cells(1,11) = null          wb.save          wb.close true        else         'if file opened , has 10 columns of data, makes no changes, closes it.           wb.close       end if   end if  next xl.quit 

your evil global

on error resume next 

hides errors. disable/remove , test again.

your

wb.close savechanges=true 

passes boolean result of comparing savechanges (undefined/empty) vs. boolean literal true. perhaps copied vba code

wb.close savechanges:=true  

(mark colon) not legal in vbscript?

and

set xl = createobject("excel.application") 

should paired an

xl.quit 

if invoke excel in loop, terminate there. try start/quit excel out of loop, should test approach carefully.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -