B
Beeawwb
Hi everybody,
Tidying up my code today and I realise that my error trapping is no longer
working. I previously realised that when using oDoc.Unprotect, if the
password was incorrect I would get error 5485. So I put in code to trap this.
If Err.Number = 5485 Then
Dim ErrorMsg
Logfile.Output "Document protected by password."
ErrorMsg = MsgBox("This document contains a password. Please unprotect
manually before use.", vbCritical, "Password Detected")
Else: MsgBox (Err.Number & " - " & Err.Description)
End If
The problem is, I've just tested this with a password protected document,
and sure enough, an error occurs when doing oDoc.Unprotect, however it gives
Err.Number as 0. When I turn off the error handling (On Error goto
ErrorCatch) I correctly get a Microsoft Visual Basic error, "Run-time error
'5485': The password is incorrect"; End; Debug; Help.
So the error is clearly the right one, just the Err object is not holding
the Number correctly. I notice in my Locals window, that there is no "Err"
object. I thought Err was a global that always existed. Or do I have to
explicitly define it?
Thanks for your help,
-Bob
Tidying up my code today and I realise that my error trapping is no longer
working. I previously realised that when using oDoc.Unprotect, if the
password was incorrect I would get error 5485. So I put in code to trap this.
If Err.Number = 5485 Then
Dim ErrorMsg
Logfile.Output "Document protected by password."
ErrorMsg = MsgBox("This document contains a password. Please unprotect
manually before use.", vbCritical, "Password Detected")
Else: MsgBox (Err.Number & " - " & Err.Description)
End If
The problem is, I've just tested this with a password protected document,
and sure enough, an error occurs when doing oDoc.Unprotect, however it gives
Err.Number as 0. When I turn off the error handling (On Error goto
ErrorCatch) I correctly get a Microsoft Visual Basic error, "Run-time error
'5485': The password is incorrect"; End; Debug; Help.
So the error is clearly the right one, just the Err object is not holding
the Number correctly. I notice in my Locals window, that there is no "Err"
object. I thought Err was a global that always existed. Or do I have to
explicitly define it?
Thanks for your help,
-Bob