• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA SendKeys + Eingabe

lion

New Member
Hi zusammen,

Ich schreibe ein Makro in Word bei dem zu jedem Tastenschlag des Benutzers ein SendKeys + die Taste getippt werden. Gibt es da eine Möglichkeit das SendKeys auf eine weitere Eingabe wartet?

?
1
2
3
4
5
6
7
8
9
10
Sub Makro2()
'
' Makro2 Makro
'
'
Do While blnA = True
SendKeys "M" + ??
DoEvents
Loop
End Sub

Das hier beschreibt eine Idee von mir etwas, vielleicht hilfts. Ansonsten bin ich aber für alles offen :D

Vielen Dank im Voraus
 
Sorry, my bad.
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
Code:
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
Code:
Public Sub FormelOeffnen()
'
    If blnA = True Then
        blnA = False
    Else
        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:
Code:
Sub Makro2()
'
' Makro2 Makro
'
'
Do While blnA = True
SendKeys "M" + ??
DoEvents
Loop
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!
Best,
Lion
 
Back
Top