View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Stephen C Stephen C is offline
external usenet poster
 
Posts: 51
Default Excel macro to open a password protected workbook

I tried that command but get the same outcome, it asks for the password.

The file path name is correct and it opens if i type in the password.

If i set an incorrect password in the code it has the same affect.

It seems to ignore the password.

Any ideas??


"JLatham" wrote:

Try this format of the .Open command:

Sub OpenPWProtectedBook()
Workbooks.Open "C:\Settings.xls", , , , "1234"
End Sub

That works for me on a workbook protected against opening without providing
a password with that password. Make sure you have your path to the file
correct also.

"Stephen C" wrote:

I have a macro that will open an Excel workbook, The workbook is password
protected and therefore promts me for the password.

I would like the macro to automatically fill in the password and open the
file.

I have tried adding the password to the vba code but it still asks for the
password.

My code is as follows

Workbooks.Open Filename:= _
"C:\Settings.xls", Password:="1234"

I have tried recording a macro while opening the file and entering the
password but it does not show the password in the code.

I am using Windows XP SP2 with Excel 2000 SP3