Opening a password protected Excel workbook?

Danny

New Member
Hi..

Have read previous threads on this subject, but cannot comment further as the thread is now closed..

I tried the two solutions; Modifying the Open Workbook Process in MS Excel VBO which whilst I really liked the method, did not work for me. The second was to create a new version of the VBO and spy the pop up boxes; I have got this solution to work from within the VBO itself but when my Process Action runs the Launch page in my VBO, I get the following message.. Internal : No resource specified for action..

Suggestions or alternative methods greatly appreciated..

Many Thanks
 

VJR

Well-Known Member
Hi @Danny,

Modifying the Excel VBO with a password parameter will be the best way to always open the file without any issues.

Do everything as exactly mentioned in @anisjolly's post here. (clicking this link will take you to the direct post)
http://rpaforum.net/threads/opening-a-password-protected-excel-workbook.470/post-659

Only one additional thing is that along with the adding of parameter to the Code stage shown in the post, you will need to add the password parameter to the Start stage of the new copy of the duplicate page that you just created. For ex: you created a duplicate page called 'Open Workbook with password' out of the original page named 'Open Workbook'. Then the below needs to be added to the Start stage of 'Open Workbook with password' page.
Start Stage Properties.JPG

Save and Publish the new action page, hit Refresh, and this parameter will now show up in the Action stage when you use the MS Excel VBO and I think that was the reason you mentioned it didn't work for you. I've tried this and it works perfectly fine. Please post back in case you are facing any issues.
 
Last edited:

Danny

New Member
Thanks VJR...

I've done some more testing and research and have found the code was not quite right for me..

The Workbook open has two methods; Password to Open & Password to Modify..

It appears "Password:=password" is Password to Open and "WriteResPassword:=password" is Password to Modify..

The Workbook I was opening had a Password set to Modify..

I amended the code to;

Dim wb as Object = GetInstance(handle).Workbooks.Open(Filename:=filename, WriteResPassword:=password)
name = wb.Name
wb.Activate()

and the file now open's..

Many Thanks
 

VJR

Well-Known Member
Okay great, now this thread has both the solutions....Open a Workbook with password to 'Open' and password to 'Modify' :)
 

charlotte liu

New Member
Dear Sir :

I still cannot set password directly with the code.

Original code of my "open workbook" is :
-------
name = ExecWithTimeout(Timeout, "Open Workbook",
Function()
Dim instance = GetInstance(handle)
Dim workbooks As object = GetProperty(instance, "Workbooks")
Dim wb As Object = Invoke(workbooks, "Open", filename)
Invoke(wb, "Activate")
Return wb.Name
End Function)
--------

Is the code directly replace all or replace part of it?
I tried to replace all or replace line 5 but cannot set password string to excel pup up password window.
The process stop at password insert window and didn't insert the password variable I created in Input
 

kiranpudi

New Member
Thanks VJR...

I've done some more testing and research and have found the code was not quite right for me..

The Workbook open has two methods; Password to Open & Password to Modify..

It appears "Password:=password" is Password to Open and "WriteResPassword:=password" is Password to Modify..

The Workbook I was opening had a Password set to Modify..

I amended the code to;

Dim wb as Object = GetInstance(handle).Workbooks.Open(Filename:=filename, WriteResPassword:=password)
name = wb.Name
wb.Activate()

and the file now open's..

Many Thanks
Do we need to import any DLL as we are using GetInstance

Thanks,
Kiran
 
Top