• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code in existing code to open when workbook encrypt with password.

Hi Members,

Please see this code it will open the workbook but now this workbook now encrypt with password, I tried through below link but its not working so please please suggest, what will be coding.
Set sw = Workbooks.Open("C:\Documents and Settings\ramesh\Desktop\Tracker Sheet- CRM.xlsx"), password:="XXXXXXXX"

Regards

Ramesh Deo
 
Correct syntax:
Code:
Set sw = Workbooks.Open(Filename:="C:\Documents and Settings\ramesh\Desktop\Tracker Sheet- CRM.xlsx", Password:="XXXXXX")
Note that argument names are not always required, but since we want to use the 1st and 5th, we need to. Otherwise, could give extra spaces with commas like this:
Code:
Set sw = Workbooks.Open("C:\Documents and Settings\ramesh\Desktop\Tracker Sheet- CRM.xlsx",,,,"XXXXXX")
 
Hi Luke Sir,
Thanks for your suggestion. Actually when i run this code then password window is open. will it work on this.
And second one in your code, we can use spaces with commas in place of password?
 
1. Yes, if you supply the open password (password required to open file), then this should skip the dialogue
2. No, that's not right. I was trying to explain that within the parenthesis, VB is expecting different arguments. You can either call out name of specific arguments like:
(filename:="MyBook.xls",password:="My password")
or you can give the arguements in the default order, just including a comma for argument you don't specify. Since password is the 5th argument, we have some extra commas, like:
("MyBook.xls",,,,"My password")
Both ways are valid. IMO, first is preferred as it's clearer what the different arguments are.
 
Hello Luke sir,

Have a good day!!

I got back with a new query and query is if i have to open file from below mention path as this scenario. please have a look for file path carefully, i used to open it manually.so what will be VBA code for this .

and the scenario is as below:

upload_2014-8-27_12-25-30.png

upload_2014-8-27_12-28-38.png
 

Attachments

  • upload_2014-8-27_12-29-30.png
    upload_2014-8-27_12-29-30.png
    107.4 KB · Views: 3
You will need to give the full folder path of file. In your picture, I don't actually see an XL file, but presumably it would be something like:
(filename:="\\sipl97\Support(1)\MyBook.xls",password:="My password")
 
Hi Luke sir,
Have a Good Day !
I tried as per your suggested code but still its not skipping password window.
so how can we resolve this???

Code:
Set sw = Workbooks.Open(Filename:="\\sipl97\SUPPPORT(1)\Tracker Sheet- CRM.xlsx", Password:="XXXXXX")
 
Last edited:
Back
Top