Mart
(KiX Supporter)
2015-10-12 09:34 PM
Open password protected Excel workbook

Hi guys,

It seems to be possible to open a password protected Excel file but somehow I'm not getting the correct results. Excel opens the workbook just fine but it keeps asking for a password. It should be auto entered by the open line. See: this link, this link and this link.
Am I missing something? Is this not possible in kix? Am I just dumb and blind when it comes to COM stuff?

BTW: this is about the "Open file" password not the "Edit file" password.

 Code:
Break on

$objExcel = CreateObject("Excel.Application")

$objWorkBook = $objExcel.Workbooks.open("d:\somefolder\book1.xlsx",Password:="Test123")

$objexcel.Visible = True


Mart
(KiX Supporter)
2015-10-12 09:47 PM
Re: Open password protected Excel workbook

Nevermind.

Fixed it. The password is the fifth parameter and not the second as shown in my first links. See: link.

 Code:
Break on

$rc = SetOption("WrapatEOL", "On")

$objExcel = CreateObject("Excel.Application")
? @ERROR
? @SERROR

$objWorkBook = $objExcel.Workbooks.open("D:\some folder\book1.xlsx",,,,"Test123")
? @ERROR
? @SERROR
Sleep 5

$objexcel.Visible = True


works fine.


Mart
(KiX Supporter)
2015-10-12 09:52 PM
Re: Open password protected Excel workbook

And (off course) the Password:= part messes things up a bit

NTDOCAdministrator
(KiX Master)
2015-10-15 07:59 PM
Re: Open password protected Excel workbook

Haven't really needed but nice to know how if I ever do. Thanks for posting