VBA word change keys

Mar 12, 2022
Reaction score
I am working on a project that includes changing certain keys on the keyboard.
It is supposed to have two different sets of keys within the same keyboard. By klicking a key combination (a Macro) the settings should change between these keyboards. So normally the key "A" gives an "A", but when the keyboard change is activated it is supposed to print for example a "B" when the "A" key is pressed. Let the use of such a problem be my thing... ;)

So what i have sofar:

I create a variable like the following
Option Explicit
Dim blnA As Boolean

If a certain macro is activated (key combination pressed) this boolean variable gets set to true, meaning that the alternative keyboard is not active
Public Sub FormelOeffnen()
    If blnA = True Then
        blnA = False
        blnA = True
    End If
End Sub

In the part on top you can see that I am struggeling to find a way to change the keys....
The probably most stupid idea was that i would create macros for each key that i want to change and dependent on whether blnA is true or false it would print the certain key.
However, that mean that i would have to hold down "Strg" as Word Macros only take key combinations instead of single keys.
And here comes the stupid part of that idea: So i would need to figure out a way, so that when the keyboard is changed a "Strg" is constantly pressed. (It would be fine, if i couldn't use any other key anymore)
But I didn't figure out how to hold a key pressed.

I tried to use Sendkeys like that:
Sub Makro2()
' Makro2 Makro
Do While blnA = True
SendKeys "M" + ??
End Sub

But in that case Sendkeys isn't fast enough and it only reacts to some of my "A" presses, when they by coincidence get hit at the same time.

So does anyone have an idea how to do that, an idea how to activate macros by just one key like "A" or a way to rewrite what keys give out?
Thank you in advance!

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