Checking the value of the text

J

Joanne

I would like to write a macro that searches for a semi-
colon and then deletes the character to the left of the
semi-colon only if that character is a punctuation mark
and not an actual letter or number. I assume I will use
the CHR command but I'm not quite sure how to put this all
together. Thank you in advance for any help you can
provide.
 
D

Dave Lett

Hi Joanne,

You can use something like the following:

With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
''' add more punctuation marks
''' between "[]" if there are
''' other characters you want
''' replaced
.Text = "([.,\?\!])(;)"
.MatchWildcards = True
With .Replacement
.ClearFormatting
.Text = "\2"
End With
.Execute Replace:=wdReplaceAll
End With
End With

HTH,
Dave
 

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