In a textbox, prevent certain typed characters from appearing. (Word and VBA)
Posted on 2011-10-19
Using VBA with Word, I have a textbox and want to block certain characters typed so that they do not appear in the text. Specifically I want to put into the KeyPress Sub code that will intercept an apostrophe, check the letter to the left of where the apostrophe will go in the text, and if it is an “e” I want to replace that character with an “é”. In other words, I want to change “e'” to “é”. I have code that will do that now if the insertion point is at the end of the words being written. I hope soon to be able to do that when the insertion point is elsewhere in the text. What I cannot figure out is that after I have made the change, how do I get the apostrophe not to appear after the revised letter?
Thanks for any help. If I can get this solution, I can simplify the typing of accented letters in a textbox.