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 2006

Tip: Looking for answers? Try searching our database.

Error handling in VBA code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hstijnen - 04 Aug 2006 10:45 GMT
Hi,

I've developed the following function to test if some style does exist in a
document:

Function xstyle(aStyle As String) As Boolean
  Dim sty As style
  On Error GoTo notexist
  Set sty = ActiveDocument.Styles(aStyle)
  Set sty = Nothing
  xstyle = True
  Exit Function
notexist:
  xstyle = False
End Function

For some time this has worked, but now when the style does not exist the
statement "Set sty = ActiveDocument.Styles(aStyle)" generates an error "the
asked member of the collection does not exist" and stops execution in stead
of jumping to the label Notexist:.

What can be at hand? Why the error handling doesn't work?

Thanks for suggestions

Henk
Jezebel - 04 Aug 2006 11:18 GMT
In VBA, go to Tools > Options. On the General tab, clear the 'Break on all
errors' checkbox.

> Hi,
>
[quoted text clipped - 25 lines]
>
> Henk
hstijnen - 04 Aug 2006 12:02 GMT
Thanks, Jezebel, it works.

Do you know how and where this option is stored? I mean, is it stored in the
VBA project, so that all my users have it, or is it personal for the users,
so that all users must set this option. In the last case, i s there VBA code
to do it automaticly in startup? (I've recorded my setting of the of the
option, but is didn't result in code)

Regards,
Henk

> In VBA, go to Tools > Options. On the General tab, clear the 'Break on all
> errors' checkbox.
[quoted text clipped - 28 lines]
> >
> > Henk
Jezebel - 04 Aug 2006 12:11 GMT
No, I don't know where it's stored; but it's certainly local. It's switched
off by default, so you don't normally have to worry about it. If your users
don't play around in VBA, it won't be an issue; and if they do, well then
it's their problem, not yours.

> Thanks, Jezebel, it works.
>
[quoted text clipped - 45 lines]
>> >
>> > Henk
 
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.