Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Excel macro to open a password protected workbook

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Excel macro to open a password protected workbook

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Excel macro to open a password protected workbook

When I do this, the workbook either opens successfully or I get a runtime error
that says I supplied the wrong password.

And I think that not recording the password is a security measure. If I'm using
your pc to open a top secret workbook and you turned on the macro recorder, then
you could get the password by looking at the recorded code.



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


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Excel macro to open a password protected workbook

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

It seems to ignore the password.

Any ideas??


How can you get the password to show in the code? when i have turned on the
macro recorder then opened the file inputting the password it does not list
it in the code.


"Dave Peterson" wrote:

When I do this, the workbook either opens successfully or I get a runtime error
that says I supplied the wrong password.

And I think that not recording the password is a security measure. If I'm using
your pc to open a top secret workbook and you turned on the macro recorder, then
you could get the password by looking at the recorded code.



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


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Excel macro to open a password protected workbook

For what password are you being prompted?

Is it to open the workbook--or to update the workbook?

If you're being prompted to allow write access:

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

And you have to know the password and type it (them?) into your code.


Stephen C wrote:

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

It seems to ignore the password.

Any ideas??

How can you get the password to show in the code? when i have turned on the
macro recorder then opened the file inputting the password it does not list
it in the code.

"Dave Peterson" wrote:

When I do this, the workbook either opens successfully or I get a runtime error
that says I supplied the wrong password.

And I think that not recording the password is a security measure. If I'm using
your pc to open a top secret workbook and you turned on the macro recorder, then
you could get the password by looking at the recorded code.



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


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Excel macro to open a password protected workbook

That is exactly what I needed.

Sorry i should have stated that it was the password to modify that i was
after not to open the file.

"Dave Peterson" wrote:

For what password are you being prompted?

Is it to open the workbook--or to update the workbook?

If you're being prompted to allow write access:

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

And you have to know the password and type it (them?) into your code.


Stephen C wrote:

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

It seems to ignore the password.

Any ideas??

How can you get the password to show in the code? when i have turned on the
macro recorder then opened the file inputting the password it does not list
it in the code.

"Dave Peterson" wrote:

When I do this, the workbook either opens successfully or I get a runtime error
that says I supplied the wrong password.

And I think that not recording the password is a security measure. If I'm using
your pc to open a top secret workbook and you turned on the macro recorder, then
you could get the password by looking at the recorded code.



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

--

Dave Peterson


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Excel macro to open a password protected workbook

You got lucky <vbg.

There was another question that asked about the read/write password and I
figured that you must be having a similar problem.

Stephen C wrote:

That is exactly what I needed.

Sorry i should have stated that it was the password to modify that i was
after not to open the file.

"Dave Peterson" wrote:

For what password are you being prompted?

Is it to open the workbook--or to update the workbook?

If you're being prompted to allow write access:

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

And you have to know the password and type it (them?) into your code.


Stephen C wrote:

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

It seems to ignore the password.

Any ideas??

How can you get the password to show in the code? when i have turned on the
macro recorder then opened the file inputting the password it does not list
it in the code.

"Dave Peterson" wrote:

When I do this, the workbook either opens successfully or I get a runtime error
that says I supplied the wrong password.

And I think that not recording the password is a security measure. If I'm using
your pc to open a top secret workbook and you turned on the macro recorder, then
you could get the password by looking at the recorded code.



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

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Open Password Protected XLS File

Follwing code will open pwd protected file if the pwd is right

Dim wk As Workbook
Set wk = Application.Workbooks.Open("C:\test.xls", , , , "testpwd", True)
'True is required for editing the file

wk.Password = "newpwd"
wk.Save
wk.Close

For unprotected files use this and tehn set pwd
Dim wk As Workbook
Set wk = Application.Workbooks.Open("C:\test.xls", True)


wk.Password = "newpwd"
wk.Save
wk.Close
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Macro to open password protected workbooks? DBM[_2_] Excel Discussion (Misc queries) 3 March 30th 07 04:48 PM
How to see macro code of a password protected macro without a password? Dmitry Kopnichev Excel Worksheet Functions 5 October 27th 05 09:57 AM
How do I save a password protected Excel doc in order to open? Stamperfiend Excel Discussion (Misc queries) 4 August 25th 05 11:56 PM
Multiple workbook user's with Master workbook - all password protected Yvon Excel Discussion (Misc queries) 2 March 30th 05 01:34 PM
Can one open a password protected Lotus 1-2-3 (wk4) file from Exce FCZ Excel Discussion (Misc queries) 0 January 3rd 05 09:03 PM


All times are GMT +1. The time now is 09:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"