excel - Visual Basic runtime error 1004 -


i trying write visual basic script run windows task scheduler. script supposed open delimited text file excel , save .xlsx file.

function importtext()  path = "c:\users\username\documents\" infile = "2014_1_31_data_parse.txt" outfile = "2014_1_31_data_parse.xlsx"  set objexcel = createobject("excel.application") objexcel.workbooks.opentext filename:=path & infile, other:=true, otherchar:="^"  objexcel.activeworkbook.saveas filename:=path & outfile  objexcel.quit wscript.quit wscript.echo "completed"  end function 

currently gives run-time error of 1004 file can not found. file there.

there few issues code, first thing change method call syntax. using named parameters (which guess comes recorded macro?).

objexcel.workbooks.opentext filename:=path & infile, other:=true, otherchar:="^" 

should changed to

objexcel.workbooks.opentext path & infile, , , , , , , , , , true, "^" 

that's quite easy see if use intellisense in vba editor.
once you've solved that, have issues error handling , other stuff gets harder when application invisible, that's different story


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -