• 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.

How to provide password by macro

ThrottleWorks

Excel Ninja
I have various macros, I need to open a particular file while running all these macros.

This file is password protected, I enter the password manually to open the file.


Is there any way where the macro itself will enter the password while opening the file.
 
If you know the relevant passwords then Workbooks.Open method has necessary arguments to provide passwords like below:

[pre]
Code:
Public Sub OpenFileWithPwd()
Dim wb As Workbook
Set wb = Workbooks.Open(Filename:="C:Test.xlsx", UpdateLinks:=True, _
ReadOnly:=False, Password:=123, WriteResPassword:=123, _
IgnoreReadOnlyRecommended:=True)
End Sub
[/pre]

Read the documentation regarding Workbooks.Open method to know about the options.


Hth,
 
Shrivallabha ji thanks a lot, Sorry for the late reply, I am trying this, will share the results.


Have a nice weekend to you & the litle star :)
 
Back
Top