Opening Excel file that requires password to Open

DWB82

New Member
Joined
Jun 4, 2015
Messages
18
Hi All

I am hoping that someone can help me. I am attempting to open an excel file which needs a password at start up.

I have tried using the code below:

"Sub OpenWbWithPassword()
Application.DisplayAlerts = False

Workbooks.Open Filename:="S:\Site\Training Files\Training_Tracker\Template.xlsm", Password:="123"

Application.DisplayAlerts = True

End Sub"

When this code is ran I get a notification box titled password. This box details the file name and that the file is protected. The protection was added to the file by going through the save as option, selecting tools, general Options and entering the password in to the password to open box.

I have been searching for a while now and cant seem to find a way around the issue. Can any one please help with this.

Thank you in advance

Dominic
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try :
Code:
[COLOR=#333333]Sub OpenWbWithPassword() [/COLOR]
[COLOR=#333333]Application.DisplayAlerts = False[/COLOR]

[COLOR=#333333]Workbooks.Open Filename:="S:\Site\Training Files\Training_Tracker\Template.xlsm", Password:="123"[/COLOR][COLOR=#ff0000], Password:="123"[/COLOR]

[COLOR=#333333]Application.DisplayAlerts = True[/COLOR]

[COLOR=#333333]End Sub[/COLOR]
 
Last edited:
Upvote 0
Or this :
Code:
Sub OpenWbWithPassword()


Application.DisplayAlerts = False


Workbooks.Open Filename:="D:\Documents\t.xlsm", Password:="123"[COLOR=#ff0000], WriteResPassword:="123"[/COLOR]


Application.DisplayAlerts = True


End Sub
 
Upvote 0
Hi

Thanks for the quick reply. When I try entering the second password argument I get the error message "Named argument already specified". when I use writeResPassword the password box still loads up.

I am unsure if this will help but I am currently using excel 2016. The password was applied to the file using excel 2007.

Thanks again for the suggestions :)
 
Upvote 0
Have you tried re-setting the password (i.e. remove the password(s) and set again) ?
 
Upvote 0
Yes removed the password from the file and saved it down, then re-applied the password to the file and attempted to run the macro again.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top