0
Const xlShiftDown = -4121
'Arquivo de entrada
strInput = WScript.Arguments(0)
'Arquivo excel
strOutput = WScript.Arguments(1)
'Arquivo excel
strFormato = WScript.Arguments(2)
Set objExcel = CreateObject("Excel.Application")
objExcel.DisplayAlerts = FALSE
objExcel.Visible = FALSE
Set objWorkbook = objExcel.Workbooks.Open(strInput)
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Columns("BL:BM").Delete
objWorksheet.Columns("AP:BA").Delete
objWorksheet.Columns("AM:AN").Delete
objWorksheet.Columns("AK:AK").Delete
objWorksheet.Columns("O:AI").Delete
objWorksheet.Columns("B:F").Delete
objExcel.ActiveWorkbook.SaveAs strOutput, strFormato
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
Call from the method below:
cscript S:\j\users\sclytr\filtroTabelaExtratoHotel.vbs "S:\j\users\sclytr\tabelas_extrato_hotel\5441e896290e48a7b16677ac4770b50a.xls" "S:\j\users\sclytr\tabelas_texto\tabelas_extrato_hotel.txt" 20
Error message below:
S: j users sclytr filtroTabelaExtratoHotel.vbs(34, 1) Microsoft Excel: Workbook class Saveas method failed
difficult to know without catching the error, but has the possibility of being related to permission, since it is a write operation. You tried to run the command as Administrator?
– Leandro Angelo
Good afternoon Leandro. I tried now and the same error occurred. The ultimate goal is to convert an xls to a txt. but I always get this error. What strangely didn’t happen yesterday.
– David Gabriel Oliveira
Well, if the code was working yesterday, it wasn’t changed, today it has an error... what changed from yesterday to today? The input file, the output file that already exists and can’t be overwritten? Think about what’s different today...
– Leandro Angelo
Indeed. The procedures were, remove the FALSE from the objExcel.Displayalerts, so he showed me an alert that said he could not access the output file. Solved this, is working perfectly.
– David Gabriel Oliveira