THANKS!!
The reference you sugested is a TREASURE!
This will help me avoid problems in the future and fix a large pile of old
ones.
Thanks again!
--
Gary''s Student - gsnu200827
"Peter T" wrote:
Karl Peterson has provided an excellent replacement for SendKeys
http://vb.mvps.org/samples/project.asp?id=sendinput
Import the bas module MSendInput into your VBA project. This was written for
VB5/6 so some minor changes for VBA:
- add the following constant definitions at the top of the module
Const vbShiftMask = 1&
Const vbKeyScrollLock = 145&
- find and comment any lines starting Debug.Print
- remove
#If Not VB6 Then
Private Function Split etc
though if you need to cater for Excel97 you'll need to do something like
this
' Break into pieces, if possible.
#If VBA6 Then
pieces = Split(this, " ")
#Else
pieces = Split97(this, " ")
' Karl's VB5 function needs a little adaptation for Excel97
#End If
Looks like you want the cursor in after the 3rd character, I'd do it like
this
Sub test2()
Dim sKeys As String
Dim editPos As Long, i As Long
' Excel needs to be the active window
' so run this from alt-F8 or a button, or API activate
Range("B2").Select ' contains 3+ characters
sKeys = "{F2}{HOME}"
editPos = 3
For i = 1 To editPos
sKeys = sKeys & "{RIGHT}"
Next
' Application.SendKeys sKeys
' or in Vista / Win7
MySendKeys sKeys
End Sub
Regards,
Peter T
"Gary''s Student" wrote in message
...
I have a cell that already contains some text. I need a macro that:
1. selects the cells
2. opens it for editting (like touching F2)
3. positions the editting cursor just after the third character in the
cell
So, for example, if the cell contains:
Now is the time
and the user runs the macro, any text the user types next would be entered
just after the Now
My first attempt was:
Sub editt()
Range("B2").Select
Application.SendKeys ("{F2}")
For i = 1 To 100
Application.SendKeys ("{LEFT}")
Next
For i = 1 To 3
Application.SendKeys ("{RIGHT}")
Next
End Sub
This works, but only for machines that accept SendKeys.
I can't figure out how to enter edit mode without SendKeys ??
--
Gary''s Student - gsnu200827