LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Why does sendkeys seem to loop

When a user types the space bar, I want 1 space, but if they type
<Ctrl+space I want to insert 5 spaces where the cursor is in the text box
(sort of simulating a tab, but I want to keep the tab key for moving focus
from this control to the next).

If the message box line is commented out, spaces keep getting added in what
seems like an endless loop. If the message box line us uncommented and
allowed to execute, then 5 spaces are added along with the original space
making a total of 6 (1 space too many). If I change the keycode = 32 to
keycode = 188 (a comma, I think) then the correct number of spaces is added
and there is no ",".

How can I fix this?
Thanks,
Geoff

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 32 And Shift = 2 Then
'MsgBox "Both the <ctrl key and <spc key were pressed"
SendKeys " ", False 'inserts 5 spaces
End If
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sendkeys string hawki Excel Discussion (Misc queries) 4 May 11th 07 08:30 PM
How Can I Use SendKeys in MAC EXCEL? kenji4861 Excel Programming 1 October 29th 03 07:24 AM
Sendkeys GB[_3_] Excel Programming 0 September 16th 03 10:39 PM
SendKeys Ron de Bruin Excel Programming 3 August 25th 03 10:21 PM
sendkeys mark poole Excel Programming 0 July 11th 03 03:47 PM


All times are GMT +1. The time now is 05:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"