Hello. Excel 2003.
If my code opens a workbook leaving the user to supply the necessary password, if they get it wrong a VBA End/Debug dialog appears. How can I handle this 'gracefully'. Do I need error handling code or can I get Excel to ask again?
Thanks, Andy.
Check Excel password VBA
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Check Excel password VBA
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Re: Check Excel password VBA
I would be inclined to use code similar to the following:agibsonsw wrote:Hello. Excel 2003.
If my code opens a workbook leaving the user to supply the necessary password, if they get it wrong a VBA End/Debug dialog appears. How can I handle this 'gracefully'. Do I need error handling code or can I get Excel to ask again?
Code: Select all
Dim ctr As Long
Pwd_Reqd:
If ctr = 3 Then GoTo ExitHandler
On Error Resume Next
Workbooks.Open Filename:= _
"C:\Documents and Settings\Wells\My Documents\Trash.xls"
If Err Then
ctr = ctr + 1
On Error GoTo 0
GoTo Pwd_Reqd
End If
Regards
Don
Don
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Check Excel password VBA
Hi and thanks for this. IDHTY.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Re: Check Excel password VBA
IDHTY; Huh???agibsonsw wrote:Hi and thanks for this. IDHTY.
Regards
Don
Don
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Check Excel password VBA
'It Did Help, Thank You' - I thought everyone new that ?
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78549
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands