Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Ant
 
Posts: n/a
Default Code for workbook protection

Hi - I have a macro which opens a file and prompts a password to open it. If
I enter the password the file opens. However, if I put in the wrong password
or hit cancel, it debugs. I am looking for some code that if the wrong
password is entered it comes up with a message to say the wrong password has
been entered - please try again. Additionally, if I hit cancel I want it to
stop the file open process.

Thanks in advance.
  #2   Report Post  
Raj
 
Posts: n/a
Default

Hi Ant

There are 2 ways out. One you can put a password in your macro. It will
facilitate 2 things, 1 no one can see or alter your code. Secondly on putting
the wrong password it won't prompt for debugging.

Secondly, you can alter your code by adding
On error

Resume next

in the beginning of the code.

I hope these methods should help you with your problem.

Regards,
Raj

"Ant" wrote:

Hi - I have a macro which opens a file and prompts a password to open it. If
I enter the password the file opens. However, if I put in the wrong password
or hit cancel, it debugs. I am looking for some code that if the wrong
password is entered it comes up with a message to say the wrong password has
been entered - please try again. Additionally, if I hit cancel I want it to
stop the file open process.

Thanks in advance.

  #3   Report Post  
Ant
 
Posts: n/a
Default

Thanks Raj - perfect!

"Raj" wrote:

Hi Ant

There are 2 ways out. One you can put a password in your macro. It will
facilitate 2 things, 1 no one can see or alter your code. Secondly on putting
the wrong password it won't prompt for debugging.

Secondly, you can alter your code by adding
On error

Resume next

in the beginning of the code.

I hope these methods should help you with your problem.

Regards,
Raj

"Ant" wrote:

Hi - I have a macro which opens a file and prompts a password to open it. If
I enter the password the file opens. However, if I put in the wrong password
or hit cancel, it debugs. I am looking for some code that if the wrong
password is entered it comes up with a message to say the wrong password has
been entered - please try again. Additionally, if I hit cancel I want it to
stop the file open process.

Thanks in advance.

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
Sheet protection code conflicts with Pivot Table "auto refresh" KG Excel Discussion (Misc queries) 6 December 21st 05 11:16 PM
Sheet Protection and VBA Code TheRobsterUK Excel Discussion (Misc queries) 1 May 27th 05 05:18 PM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 4th 05 10:50 AM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM


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