Check IF Selection is Caption?

E

Ed

I am creating a macro to insert captions on tables in my reports.
Obviously, any time I run this on a report more than once, I don't need to
insert a new caption over the top of a previous one. The macro finds the
text string I am using for the caption, which is the same text for both
inserted captions and newly-inserted tables with a generic place-holder.

Can I check the selected text for: is this a caption? or: does it contain a
number field? or; is this Caption style? My idea is to have the macro find
the caption text, then place all my code in an IF statement based on one of
the above conditions (or another one that will work, if you have any other
ideas) = FALSE. So it would be something like:

If Selection.Find.Found = True
If Selection [is caption] [contains field] [Caption style] = False
' run code
Else 'find next
End If
Else ' end game
End If

Ed
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Ed,

Try

If Not Selection.Range.Style = "Caption" Then
' Run Code
End If

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
E

Ed

Thanks, Doug. I appreciate the assist.

Ed

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
Hi Ed,

Try

If Not Selection.Range.Style = "Caption" Then
' Run Code
End If

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
Ed said:
I am creating a macro to insert captions on tables in my reports.
Obviously, any time I run this on a report more than once, I don't need to
insert a new caption over the top of a previous one. The macro finds the
text string I am using for the caption, which is the same text for both
inserted captions and newly-inserted tables with a generic place-holder.

Can I check the selected text for: is this a caption? or: does it contain
a
number field? or; is this Caption style? My idea is to have the macro
find
the caption text, then place all my code in an IF statement based on one
of
the above conditions (or another one that will work, if you have any other
ideas) = FALSE. So it would be something like:

If Selection.Find.Found = True
If Selection [is caption] [contains field] [Caption style] = False
' run code
Else 'find next
End If
Else ' end game
End If

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top