Having a bit of trouble using the SaveAs option when automating Excel. I don't get any error details other than "Document not saved". Does anyone have experience with using this particular method in Winbatch? I am using Excel 2010. Everything works up to the last line. Here is the code that I am trying to implement:
objexcel=objectopen("excel.application")
objexcel.visible=@true
objExcel.Application.DisplayAlerts = @False
file='C:\q2\estatements\03.28.14.xlsx'
exlBook=objexcel.workbooks.open("%file%")
count=exlbook.sheets.count
if count >1 then objexcel.worksheets('sheet2').delete
curr=objexcel.Worksheets("sheet1")
ColSheets=exlbook.Sheets
exlsheet=exlbook.ActiveSheet.name
curr.activate
objexcel.worksheets('sheet1').SaveAs ('FileName:="C:\q2\test.csv", Fileformat:=6')
You will need to modify the syntax for WIL. Notice the change to the format of the data passed to the SaveAs Method.
Change this line:
objexcel.worksheets('sheet1').SaveAs ('FileName:="C:\q2\test.csv", Fileformat:=6')
To :
objexcel.worksheets('sheet1').SaveAs (::'FileName="C:\q2\test.csv", Fileformat=6')
Drop the single quotes too
objexcel.worksheets('sheet1').SaveAs (::FileName="C:\q2\test.csv", Fileformat=6)
EXCELLENT!!!!!
Thanks so much. I've been banging my head against the wall on that one for a bit. I can move on to the next challenge in that program now.