Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2007

Tip: Looking for answers? Try searching our database.

Error handling: Err.Number is always 0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Beeawwb - 21 Aug 2007 07:14 GMT
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
Beeawwb - 21 Aug 2007 07:36 GMT
Oops, here I thought my PC had crashed an not posted my original thread
(which didn't show up when I logged back in.) Looks like it did and now I
have a duplicate topic. I've solved this problem in the original topic
thread, my apologies for the wasted post.

-Bob

> Hi everybody,
>
[quoted text clipped - 24 lines]
>
> -Bob
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.