user3712526
user3712526

Reputation: 11

Unable to get open property of workbook class VBS

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.

Upvotes: 0

Views: 5246

Answers (1)

phd443322
phd443322

Reputation: 503

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)

Upvotes: 1

Related Questions