vbscript - VBS Object required error, 800A01A8 -
hello i'm trying debug script inherited below. error on line 71 char 6. object required 'ofile'
i don't have vbs experience please gentle. script takes scan , uploads doc archive server, gives unique filename etc. haven't figured out 'ofile' yet :/
'feb 18, 2005 dim ofso set ofso = createobject("scripting.filesystemobject") hiddencount = 0 'wscript.echo wscript.arguments(0) if wscript.arguments.count = 1 , ofso.folderexists(wscript.arguments(0)) set scanfiles = ofso.getfolder(wscript.arguments(0)).files each ofile in scanfiles if ofile.attributes , 2 hiddencount = hiddencount + 1 end if next else set scanfiles = wscript.arguments end if filecount = scanfiles.count - hiddencount 'wscript.echo hiddencount 'wscript.echo filecount 'wscript.quit() set oie = wscript.createobject("internetexplorer.application") oie.left=50 ' window position oie.top = 100 ' , other properties oie.height = 300 oie.width = 350 oie.menubar = 0 ' no menu oie.toolbar = 0 oie.statusbar = 1 oie.navigate "http://gisweb/apps/doc_archive/scan_login.php?file_count="&filecount 'wscript.echo filecount oie.visible = 1 ' important: wait till msie ready while (oie.busy) loop ' wait till user clicks ok button ' use checkval function ' attention: note m. harris, can make ' script bit more fool proof. need catch case ' user closes form without clicking ok button. on error resume next ' wait till ok button clicked wscript.sleep 400 loop while (oie.document.script.checkval()=0) ' if error occur, because form closed, quit ' script if err <> 0 wscript.echo "sorry, run-time error occured during checking" & _ " ok button " & vbcrlf & _ "error: " & err.number & " " & _ "i guess form getting closed..." wscript.quit ' end script end if on error goto 0 ' switch error handling off ' user has clicked ok button, retrieve values doclist = oie.document.validform.doc_id_list.value 'msgbox doc_id = 0 100000 x = 1 next oie.quit() ' close internet explorer set oie = nothing ' reset object variable docarray = split(doclist,",") = 0 each ofile in scanfiles if not ofile.attributes , 2 **error here** ext = ofso.getextensionname(ofile) filename = "p"&right("000000"&docarray(i),6)&"."&ext base = int(docarray(i) / 500) * 500 subdir = "d"&right("000000"&base,6) ofso.copyfile ofile, "\\ditgis02\enterprise_gis\doc_archive\raw\"&subdir&"\"&filename, true = + 1 end if next if wscript.arguments.count = 1 , ofso.folderexists(wscript.arguments(0)) set wshshell = wscript.createobject("wscript.shell") intbutton = wshshell.popup (filecount&" file(s) logged , copied! want delete temporary scan files?",0,"done!",4) if intbutton = 6 each ofile in scanfiles ofile.delete next end if else wscript.echo(filecount&" file(s) logged , copied!") end if wscript.quit() ' ready ' end
it looks problem may arise if initial test fails:
if wscript.arguments.count = 1 , ofso.folderexists(wscript.arguments(0)) ... else set scanfiles = wscript.arguments end if
you're setting scanfiles
variable collection of arguments, not files. later on, near line 71 (where error occurs), you're treating scanfiles
if it's files
collection , attempting access attributes
property of 1 of file
objects:
for each ofile in scanfiles if not ofile.attributes , 2 **error here** ... next
this won't possible since scanfiles
arguments
collection instead. think need fix initial else
clause either terminate script or provide kind of "default" files
collection.
Comments
Post a Comment