Unable to get open property of workbook class VBS

5.1k Views Asked by At

I'm trying to make a script that will remove the password protection for a excel (.xls) file but i keep getting the following error when I try to open my workbook:

"Unable to get the Open property of the Workbook class"

My code to open the file is:

sfPath = objArgs(0)
spassword = objArgs(1)

set objExcelFile = CreateObject("Excel.Application")
set objWorkbook = objExcelFile.Workbooks.Open(sfPath, spassword)

Any help would be much appreciated.

1

There are 1 best solutions below

0
On

Did you read the docs.

You code is passing a string instead of a number specifing to update links or not. Password is the 5th parameter.

expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad, OpenConflictDocument)