For all the complaints that Vista broke this, and Vista broke that,
Vista really didn't break Classic VB all that badly. That said,
one VB statement
did truly get hammered. This sample provides a drop-in replacement for the
standard SendKeys statement, and should work just fine in all the environments
(VB5, VB6 IDE, VBA other than Office 2007) where this broke. I believe it's
written to exactly emulate SendKeys, without exception <g>.
Well, all but one "feature" of SendKeys, at any rate -- the Wait
parameter. Can anyone tell me what that's all about? My routine accepts, but
ignores, this parameter.
As you'll see, using MySendKeys is absolutely identical to native SendKeys:
Private Sub Command1_Click()
Text1.SetFocus
Call MySendKeys(Text2.Text)
DoEvents
Command1.SetFocus
End Sub
Private Sub Command2_Click()
Text1.SetFocus
Call VBA.SendKeys(Text2.Text)
DoEvents
Command2.SetFocus
End Sub
Private Sub Form_Load()
Text2.Text = "{home}+{end}Testing123+(123)"
End Sub
One change you may want to think about making would be to rename the
MySendKeys subroutine to SendKeys. That will avoid having to change anything
else in your code, as it will override the SendKeys statement in the VBA object
library from that point onward. In order to use the original SendKeys, you'll
then have to prefix it with "VBA." as shown above.
Note on Conditional Compilation
The MSendInput.bas module contains a conditional compilation constant that
determines whether the native language implementation of Split() is compiled in
or not. If this constant is defined as False, as it is in the download, the
module may be used in VB5 as well as VB6 and VBA.