Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default one line macro to enter password for workbook

Hi All --

What is the one line of code that will enter a password
upon opening a workbook (assuming macros are enabled)?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default one line macro to enter password for workbook

this should do it

ActiveWorkbook.Unprotect (your password)


-----Original Message-----
Hi All --

What is the one line of code that will enter a password
upon opening a workbook (assuming macros are enabled)?

Thanks.
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default one line macro to enter password for workbook

Hello Experts,
I have the same question...Opening a workbook that's needs a password
first in order to open it. But this code still doesn't work. Any
ideas?

Workbooks.Open Filename:="C:\My Documents\File1.xls"
ActiveWorkbook.Unprotect "test"

I've tried no quotations, brackets, no brackets, around the password but
of no avail. The popup for the password still surfaces. And, I do have
the correct password.

I've even tried:
Dim Password as variant
Password = "test"
Workbooks.Open Filename:="C:\My Documents\File1.xls"
ActiveWorkbook.Unprotect Password

It still prompts me to enter the password manually to open the file.
Any ideas?

Thanks in advance,
Ricky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default one line macro to enter password for workbook

Ricky,

Dim wkbk as string, pass as string
wkbk = "?????" ' include path
pass = "mypassword"
Workbooks.Open FileName:=wkbk, password:=pass


--
sb
"Ricky Pang" wrote in message
...
Hello Experts,
I have the same question...Opening a workbook that's needs a password
first in order to open it. But this code still doesn't work. Any
ideas?

Workbooks.Open Filename:="C:\My Documents\File1.xls"
ActiveWorkbook.Unprotect "test"

I've tried no quotations, brackets, no brackets, around the password but
of no avail. The popup for the password still surfaces. And, I do have
the correct password.

I've even tried:
Dim Password as variant
Password = "test"
Workbooks.Open Filename:="C:\My Documents\File1.xls"
ActiveWorkbook.Unprotect Password

It still prompts me to enter the password manually to open the file.
Any ideas?

Thanks in advance,
Ricky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default one line macro to enter password for workbook

Hi Steve,
Thanks! That's the ticket. I used this one-liner:

Workbooks.Open Filename:="C:\My Documents\File1.xls", Password:="test"

Just wondering, what's the difference between this one-liner and
Dimensioning other than setting the filename path and password up front
so that it can be recalled at a later point in the code, if needed?

Dim wkbk as string, pass as string
wkbk = "?????" ' include path
pass = "mypassword"

Thanks again,
Ricky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default one line macro to enter password for workbook

Ricky,

You got it. Also in my application I am opening multiple workbooks and
need to set the password for each. So that pass = a reference to a list and
changes in a loop.

Glad it worked for you...

--
sb
"Ricky Pang" wrote in message
...
Hi Steve,
Thanks! That's the ticket. I used this one-liner:

Workbooks.Open Filename:="C:\My Documents\File1.xls", Password:="test"

Just wondering, what's the difference between this one-liner and
Dimensioning other than setting the filename path and password up front
so that it can be recalled at a later point in the code, if needed?

Dim wkbk as string, pass as string
wkbk = "?????" ' include path
pass = "mypassword"

Thanks again,
Ricky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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 a password protected workbook Stephen C Excel Discussion (Misc queries) 8 December 1st 08 05:36 AM
Password to enter the sheet Tia[_3_] Excel Worksheet Functions 6 October 13th 08 10:37 PM
Open a workbook with a password via macro - How to? fishy Excel Discussion (Misc queries) 1 February 29th 08 02:21 PM
Macro to select cells in column enter data then press enter NP New Users to Excel 1 February 20th 08 04:21 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


All times are GMT +1. The time now is 09:40 AM.

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

About Us

"It's about Microsoft Excel"