find existence of autotext entries

  • Thread starter Thread starter Keith G Hicks
  • Start date Start date
K

Keith G Hicks

I'm cleaning up some code from a previous programmer who liked to put "On
Error Resume Next" in places where he didnt' know how to test things in
lines above code that might crash. For example, there are lines like the
following:

Selection.InsertAfter "krh"
On Error Resume Next
Selection.Range.InsertAutoText

I really want to take otu the "On Error Resume Next" and replace it with a
test to see if the AutoTextEntry exists as follows:

Selection.InsertAfter "krh"
If <autotext entry("krh")> exists Then
Selection.Range.InsertAutoText
End If


But I have no idea how to do that. I know I can use NormalTemplate in some
way but that is a problem in and of itself because we're nto using the
Normal Template all the time. I need to search that and another as well.

Anyway, some specific info on how to do this would be wonderful.

Thanks,

Keith
 
since no one else responded, I'll guess no automated to do what you want.

I mean you *could* write a little vb applet to go the code line by line, and
do the complex find and replace you have in mind. But why?

IMHO: there's nothing wrong with "on error resume next" as long as you
resume proper error handling later. I think its faster to try something,
fail, and move on that it is to test for a condition, find it to be true,
then go change something, and then move on.

I sometimes need to delete a query that may or may not be there. Rather than
test for it, I use "on error resume next" and try the delete, if it works, it
works.

Also "on error resume next" will allow the app to skip all kinds of errors,
not just the one you think you're trapping.

Complete error trapping is overrated. "on error resume next" can indeed be
part of your healthy diet, sorry, I mean propler error handling proceedures.

roger
 
Keith said:
I'm cleaning up some code from a previous programmer who liked to put "On
Error Resume Next" in places where he didnt' know how to test things in
lines above code that might crash. For example, there are lines like the
following:

Selection.InsertAfter "krh"
On Error Resume Next
Selection.Range.InsertAutoText

I really want to take otu the "On Error Resume Next" and replace it with a
test to see if the AutoTextEntry exists as follows:

Selection.InsertAfter "krh"
If <autotext entry("krh")> exists Then
Selection.Range.InsertAutoText
End If


But I have no idea how to do that. I know I can use NormalTemplate in some
way but that is a problem in and of itself because we're nto using the
Normal Template all the time. I need to search that and another as well.


I think getting rid of Resume Next is a very good idea.

The reason you are not getting an answer to your question is
probably because you asked it in a forum about coding in
Access database forms, but you appear to be using the Excel
object model. You would have much better chance of getting
a useful answer by posting your question to the appropriate
Excel forum.
 
Not sure why you're assuming Excel. The automation is for Word and the
coding is being done in Access modules in an Access 2003 (2000 format) mdb.
The word programming newsgroup has about 200 posts right now. I usually have
much better success getting answers on Word automation inside of Access in
this newsgroup or the modulescoding one. Just doesn't seem to be the case
this time.
 
Just goes to show how unfamiliar I am with Word :-\

These Access forums are very good and I think it's nice that
you prefer them to Word forums. OTOH, I suspect that you
still have a better chance in a Word forum where Word
programming experts hang out. There has got to be more than
one Word newsgroup, perhaps you could find a more helpful
one.
 
There is. I just found it. I knew about word.programming but not
word.vba.general. I've transferred this post to there. It's got a good
amount of activity. Hopefully someone there will have something.


Marshall Barton said:
Just goes to show how unfamiliar I am with Word :-\

These Access forums are very good and I think it's nice that
you prefer them to Word forums. OTOH, I suspect that you
still have a better chance in a Word forum where Word
programming experts hang out. There has got to be more than
one Word newsgroup, perhaps you could find a more helpful
one.
--
Marsh
MVP [MS Access]

Not sure why you're assuming Excel. The automation is for Word and the
coding is being done in Access modules in an Access 2003 (2000 format)
mdb.
The word programming newsgroup has about 200 posts right now. I usually
have
much better success getting answers on Word automation inside of Access in
this newsgroup or the modulescoding one. Just doesn't seem to be the case
this time.


"Marshall Barton" wrote
 
If anyone's ever looking for an answer to this, it was thoroughly answered
in the "microsoft.public.word.vba.general" newsgroup under a thread started
by me with the same subject dated 12/12/2009 and answered on 12/13/2009.

Keith
 
Back
Top