Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Password Unprotect

Absolutely.

Near the beginning of your code, enter something like:

On Error Goto ErrorTrap

(ErrorTrap can be any text label you want)

Then, add as your last lines:

Exit Sub

ErrorTrap:

If Err.Number = 1004 then
msgbox "Incorrect password. Please try again.",
vbOkOnly
endif

So your entire code would be something like:

On Error Goto ErrorTrap

{rest of code}

{last line of code}

Exit Sub

Errortrap:

If Err.Number = 1004 then
msgbox "Incorrect password", vbOkonly
endif



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

Have a very simple macro within a workbook that basically

all it does
is Unprotect a sheet that is password protected (goes to

the dialog
box in order to enter in the password),

e.g.

Sub Administrator()
ActiveSheet.Unprotect
End Sub

However if the person enters in the password incorrectly

this then
loads up the VBA module with the following error message:

Run Time Error 1004
"The password you supplied is incorrect......"

Is it possible to be able to handle errors within the VBA

module where
it just loads up a message box saying password entered is

incorrect
and has an OK button which goes back to the spreadsheet?

Appreciate your help on this, as always!

Cheers, Al Mackay ( )
.

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
How do I unprotect a workbook without the password? FJBSD Excel Discussion (Misc queries) 1 March 29th 08 11:49 PM
Unprotect password- forgot? JW Excel Worksheet Functions 4 February 29th 08 04:56 AM
how can i unprotect worksheet with no password? raf Excel Discussion (Misc queries) 2 May 21st 07 09:25 PM
I need to unprotect a worksheet but I don't have the password. FarrShadow Excel Discussion (Misc queries) 3 October 29th 06 02:02 AM
Password - Protect, UnProtect MrAlMackay Excel Programming 5 January 19th 05 07:23 PM


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