Page 1 of 1 1
Topic Options
#210829 - 2015-10-12 09:34 PM Open password protected Excel workbook
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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

- Chuck Norris once sold ebay to ebay on ebay.

Top
#210830 - 2015-10-12 09:47 PM Re: Open password protected Excel workbook [Re: Mart]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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.


Edited by Mart (2015-10-12 09:47 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#210831 - 2015-10-12 09:52 PM Re: Open password protected Excel workbook [Re: Mart]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
And (off course) the Password:= part messes things up a bit
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#210842 - 2015-10-15 07:59 PM Re: Open password protected Excel workbook [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Haven't really needed but nice to know how if I ever do. Thanks for posting
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 346 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.051 seconds in which 0.022 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org