[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Remap certain keys on the keyboard with Word Textbox and VBA

Posted on 2011-10-20
Medium Priority
Last Modified: 2012-05-12
I have a textbox in a Word document, and I want to remap certain keys so that they produce French accented characters instead of what they would normally produce.

     One example: If a user types "[", I want the textbox to show "é".

     I can capture the key pressed with the KeyPress Sub KeyAscii value. What I cannot do is change that KeyAscii value to anything over 128 (or maybe it is 127), yet if I want that character to appear (Chr(130), I guess I cannot use the KeyPress event.

     Any suggestions?  This is my third or fourth question to EE in two or three days, so I guess I am abusing your kindness is saving me weeks of work, but for the moment I have to ask this question. I presume that someone is going to save me a week or two of work by giving me an answer (if one exists).

Question by:JohnRobinAllen
LVL 76

Accepted Solution

GrahamSkan earned 1000 total points
ID: 37005690
What's the problem JRA?

If you are using an ActiveX control, then this works for me:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Select Case Chr$(KeyAscii)
        Case "["
            KeyAscii = Asc("é")
    End Select
End Sub

Open in new window


Author Closing Comment

ID: 37006382
This is exactly the solution I needed. I am puzzled at why I could not think of it earlier.
     As always, thanks!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Suggested Courses
Course of the Month19 days, 4 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question