I have inherited a text with words containing apostrophes, some of which are "curly" ’, and some straight '. In order to process the text I need a reliable search method which will produce only exact matches for my search text.
So far, whenever I search the text for a word containing a straight apostrophe (like he's), Word also returns a match for the same word containing a curly apostrophe (he’s) and I do not want this to happen. I want exact matches with ' straight apostrophes only.
The VBA instruction I'm using is:
MyRange.Find.Execute FindText:=strSearchText, Forward:=True, Format:=False, _
MatchCase:=True, MatchWholeWord:=True
Can anybody give me a hint?
From VBA's F1 help for the Find.Execute method:
To search for a symbol character, type a caret (^), a zero (0), and then the symbol's character code. For example, "^0151" corresponds to an em dash (—).
For a straight apostrophe this would be ^039. So for example, if you're searching for he's, then you will want
FindText:="he^039s"
This does not find the curly apostrophe equivalent, he’s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With