Incorrect password error on opening a workbook in VBA

aelita2u

New Member
Joined
Oct 31, 2006
Messages
34
I am trying to write a macro that opens a password protected workbook (password required to modify) and updates it with the latest set of data, then pulls the summary from that workbook into the current one. Both workbooks reside on the network and I am using excel 2007.

My code is:
Workbooks.Open Filename:= “my workbook file path”, WriteResPassword:=”my password”

I am getting a run time error ‘1004’: The password you specified is not correct. However the password is correct, the caps are not on and when I try to open the file manually with the same password it accepts it without any issues. I am stumped at what is causing this error and how I can bypass it. Any help on the matter will be greatly appreciated.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Why are you using WriteResPassword?

Shouldn't it just be Password?

Also is the password actually "my password"?:eek:
 
Upvote 0
Hi Norie,

I am using WriteResPassword because the workbook requires a password to modify not to open. If I use Password instead, on opening the workbook excel shows a password input box. The aim of this macro is to allow the user to get the latest set of data without making the password for the source file obvious.

The line of code I posted had worked for me in the past and “my password” is not the real password but I do know what the right one is.

Strangely enough I have just tried the code again and it worked a treat. No modifications were made since last night so what changed in the last 7 hours is beyond me. It works now and I am happy.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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