Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default unprotect more than one password in macro

I need to run apx 400 files thru a fix program which has already been
written by our tech. She's on vacation for a month.

The 400 files may or may not be password protected AND those that are
password protected may have one of 2 passwords. Searching here I
found the language to unprotect, I just don't know how to name the
condition of a password in order to use it in a macro.

My concept so far on how to solve this problem is to use an if then
command as follows

if "password"="pwd#1" then
ActiveSheet.unprotect "pwd#1"
else if "password" = "pwd#2: then
ActiveSheet.unprotect "pwd#2"
end if

To recap, I need to know what vba language is used to denote "password"
in the above module.

Thanks, in advance,
Morticcia



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default unprotect more than one password in macro

You can't do a check like if Password = "such and such"

You would have to furnish the password as an argument and trap the error.

Sub Unprotect()
On Error Resume Next
ActiveSheet.Unprotect Password:="ABC"
If Err.Number < 0 Then
ActiveSheet.Unprotect Password:="ABCD"
End If
Err.Clear
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy

"Morticcia" wrote in message
...
I need to run apx 400 files thru a fix program which has already been
written by our tech. She's on vacation for a month.

The 400 files may or may not be password protected AND those that are
password protected may have one of 2 passwords. Searching here I
found the language to unprotect, I just don't know how to name the
condition of a password in order to use it in a macro.

My concept so far on how to solve this problem is to use an if then
command as follows

if "password"="pwd#1" then
ActiveSheet.unprotect "pwd#1"
else if "password" = "pwd#2: then
ActiveSheet.unprotect "pwd#2"
end if

To recap, I need to know what vba language is used to denote "password"
in the above module.

Thanks, in advance,
Morticcia



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
I need to unprotect sheet so I cn sve it but need a password? scout ron Excel Discussion (Misc queries) 2 May 28th 10 03:05 PM
unprotect password in VBA view exalan Excel Worksheet Functions 1 March 4th 10 01:05 PM
How do I unprotect a workbook without the password? FJBSD Excel Discussion (Misc queries) 1 March 29th 08 11:49 PM
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
Password Unprotect Bob Tulk Excel Programming 0 July 29th 03 02:53 PM


All times are GMT +1. The time now is 10:12 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"