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.
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,561
Office Version
365
Platform
Windows
Why are you using WriteResPassword?

Shouldn't it just be Password?

Also is the password actually "my password"?:eek:
 

aelita2u

New Member
Joined
Oct 31, 2006
Messages
34
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,549
Messages
5,469,375
Members
406,647
Latest member
ssinovec

This Week's Hot Topics

Top