hello,
I have some code that reads a tabbed delimited text with a file path to an excel document and also the password which opens that doc.
the script is to open the excel file and save it to a different location without a password.
It's working now and I am adding error logging incase the wrong password is supplied.
VBscript will not error if the wrong password is supplied, but excel will. Is there a way to programmatically tell if an instance of excel is successfully opened?
I have tried using err.num, but fails because it's the instance of excel that errors and not a vbscript runtime error.
I have some code that reads a tabbed delimited text with a file path to an excel document and also the password which opens that doc.
the script is to open the excel file and save it to a different location without a password.
It's working now and I am adding error logging incase the wrong password is supplied.
VBscript will not error if the wrong password is supplied, but excel will. Is there a way to programmatically tell if an instance of excel is successfully opened?
I have tried using err.num, but fails because it's the instance of excel that errors and not a vbscript runtime error.
Code:
DO WHILE txtofFiles.AtEndOfStream <> TRUE
IF txtofFiles.AtEndOfStream <> TRUE THEN
sLinetoWrite = ""
strLine = txtofFiles.ReadLine
sLinetoWrite = "Decrypting: " & strLine
strPasswordPath = LEFT(strLine, INSTR(strLine, chr(9))-1)
strPassword = RIGHT(strLine, LEN(strLine) - INSTRREV(strLine, chr(9)))
strFileName = RIGHT(strPasswordPath, LEN(strPasswordPath) - INSTRREV(strPasswordPath, "\"))
'MSGBOX strPasswordPath & vbcrlf & strPassword & vbcrlf & strFileName
'********include error checking here to identify if excel opens correctly****
objExcel.Workbooks.Open strPasswordPath,,,, strPassword
objExcel.Workbooks(1).SaveAs strSavePath & strFileName,,""
objExcel.Workbooks.Close
'****************************************************************************
txtLog.writeLine sLinetoWrite & " ... done"
END IF
LOOP