#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Sendkeys

Hi all,

I'm using a simple sendkey statement to paste (ctrl v) cell content to
another application. However when running the code it sometimes works (I can
see the cell content copied and pasted to the application) but most of the
times it just jumps from Excel to the other application and stops (so nothing
is pasted). Anybody got a clue what might be going on here?


Code =

Gemini:

AppActivate ("CSM - Citrix Presentation Server Client")
SendKeys ("{^V}"), True

Kind regards,

Basta
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Sendkeys

If the problem is intermittent, it may be a timing issue. Try putting a
DoEvents between your statements
--
Gary''s Student - gsnu201002


"Basta1980" wrote:

Hi all,

I'm using a simple sendkey statement to paste (ctrl v) cell content to
another application. However when running the code it sometimes works (I can
see the cell content copied and pasted to the application) but most of the
times it just jumps from Excel to the other application and stops (so nothing
is pasted). Anybody got a clue what might be going on here?


Code =

Gemini:

AppActivate ("CSM - Citrix Presentation Server Client")
SendKeys ("{^V}"), True

Kind regards,

Basta

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Sendkeys

Hi Gary,

Thank you for your help but it doesn't solve my problem. What happens is
when I run the procedure;

1. It jumps to the other application (this works)
2. Select an inputbox with shortcode ALT+S (this does not work)
3. Paste data with shortcode CTRL+V (this works)

The code I use for the ALT+S is;
SendKeys "%S", True

The code I use for the CTRL+V is;
SendKeys "^V", True

In essence both lines are the same, though I tried putting one of them in
brackets which didn't solve my problem. This probably expalins my situation a
bit better. Maybe you, or someone else, can make something out if it 'cause
I'm lost here

Greetz

Basta

"Gary''s Student" wrote:

If the problem is intermittent, it may be a timing issue. Try putting a
DoEvents between your statements
--
Gary''s Student - gsnu201002


"Basta1980" wrote:

Hi all,

I'm using a simple sendkey statement to paste (ctrl v) cell content to
another application. However when running the code it sometimes works (I can
see the cell content copied and pasted to the application) but most of the
times it just jumps from Excel to the other application and stops (so nothing
is pasted). Anybody got a clue what might be going on here?


Code =

Gemini:

AppActivate ("CSM - Citrix Presentation Server Client")
SendKeys ("{^V}"), True

Kind regards,

Basta

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Sendkeys

A DoEvents might not be enough.
I would use a call to SLEEP API function within a loop to avoid
freezing Excel.

Declare Sub Sleep lib "kernel32" (ByVal dwMillisecs as Long)

Sub Doze(Millisecs as long)
Dim i as Long
for i = 1 to Millisecs/10
Sleep(10) 'freeze your code for 10 milliseconds
next i
End Sub

Depending on the sluggishness of your system, you may need to call
Doze with a value of up to 2000 (= 2 second) to allow the app getting
activated and able to receive the SendKeys.
Usually 200 to 300 should be sufficient.

HTH.

Helmut.


"Gary''s Student" schrieb im
Newsbeitrag ...
If the problem is intermittent, it may be a timing issue. Try putting a
DoEvents between your statements
--
Gary''s Student - gsnu201002


"Basta1980" wrote:

Hi all,

I'm using a simple sendkey statement to paste (ctrl v) cell content to
another application. However when running the code it sometimes works (I can
see the cell content copied and pasted to the application) but most of the
times it just jumps from Excel to the other application and stops (so nothing
is pasted). Anybody got a clue what might be going on here?


Code =

Gemini:

AppActivate ("CSM - Citrix Presentation Server Client")
SendKeys ("{^V}"), True

Kind regards,

Basta



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Sendkeys

Basta,

As noted by others on the thread, and from your observations, SendKeys is
quite temperamental. Initially, when I used to use SendKeys I discovered
issues with wait times and code debugging. For example, the "wait" argument
of SendKeys never seemed to work, DoEvents sometimes did the trick, and
Application.Wait or Sleep was almost always needed. Despite using these
tricks to get SendKeys to work properly, I found it to be unreliable. (As a
side note, I discovered that if I ran a procedure without any breakpoints, I
could better test SendKeys; however, if I stopped or interrupted the code
prior to a procedure completing its execution, then SendKeys never worked
properly).

Anyhow, I finally got so frustrated with SendKeys that I moved over to a
number of API calls that work by grabbing handles to specific windows (i.e.
windows, combo boxes, text boxes, etc.) and then sending messages to those
handles. Though this was a significant investment in time and resources,
I've never run into any SendKeys issues (including reliability).

Best,

Matthew Herbert


"Helmut Meukel" wrote:

A DoEvents might not be enough.
I would use a call to SLEEP API function within a loop to avoid
freezing Excel.

Declare Sub Sleep lib "kernel32" (ByVal dwMillisecs as Long)

Sub Doze(Millisecs as long)
Dim i as Long
for i = 1 to Millisecs/10
Sleep(10) 'freeze your code for 10 milliseconds
next i
End Sub

Depending on the sluggishness of your system, you may need to call
Doze with a value of up to 2000 (= 2 second) to allow the app getting
activated and able to receive the SendKeys.
Usually 200 to 300 should be sufficient.

HTH.

Helmut.


"Gary''s Student" schrieb im
Newsbeitrag ...
If the problem is intermittent, it may be a timing issue. Try putting a
DoEvents between your statements
--
Gary''s Student - gsnu201002


"Basta1980" wrote:

Hi all,

I'm using a simple sendkey statement to paste (ctrl v) cell content to
another application. However when running the code it sometimes works (I can
see the cell content copied and pasted to the application) but most of the
times it just jumps from Excel to the other application and stops (so nothing
is pasted). Anybody got a clue what might be going on here?


Code =

Gemini:

AppActivate ("CSM - Citrix Presentation Server Client")
SendKeys ("{^V}"), True

Kind regards,

Basta



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Sendkeys

Hi Matthew,

Thanks for your comment on this. API and the corresponding coding something
which I'm not familiar with. Maybe, soom time soon, I will spend some time on
this.

Thnx

Basta

"Matthew Herbert" wrote:

Basta,

As noted by others on the thread, and from your observations, SendKeys is
quite temperamental. Initially, when I used to use SendKeys I discovered
issues with wait times and code debugging. For example, the "wait" argument
of SendKeys never seemed to work, DoEvents sometimes did the trick, and
Application.Wait or Sleep was almost always needed. Despite using these
tricks to get SendKeys to work properly, I found it to be unreliable. (As a
side note, I discovered that if I ran a procedure without any breakpoints, I
could better test SendKeys; however, if I stopped or interrupted the code
prior to a procedure completing its execution, then SendKeys never worked
properly).

Anyhow, I finally got so frustrated with SendKeys that I moved over to a
number of API calls that work by grabbing handles to specific windows (i.e.
windows, combo boxes, text boxes, etc.) and then sending messages to those
handles. Though this was a significant investment in time and resources,
I've never run into any SendKeys issues (including reliability).

Best,

Matthew Herbert


"Helmut Meukel" wrote:

A DoEvents might not be enough.
I would use a call to SLEEP API function within a loop to avoid
freezing Excel.

Declare Sub Sleep lib "kernel32" (ByVal dwMillisecs as Long)

Sub Doze(Millisecs as long)
Dim i as Long
for i = 1 to Millisecs/10
Sleep(10) 'freeze your code for 10 milliseconds
next i
End Sub

Depending on the sluggishness of your system, you may need to call
Doze with a value of up to 2000 (= 2 second) to allow the app getting
activated and able to receive the SendKeys.
Usually 200 to 300 should be sufficient.

HTH.

Helmut.


"Gary''s Student" schrieb im
Newsbeitrag ...
If the problem is intermittent, it may be a timing issue. Try putting a
DoEvents between your statements
--
Gary''s Student - gsnu201002


"Basta1980" wrote:

Hi all,

I'm using a simple sendkey statement to paste (ctrl v) cell content to
another application. However when running the code it sometimes works (I can
see the cell content copied and pasted to the application) but most of the
times it just jumps from Excel to the other application and stops (so nothing
is pasted). Anybody got a clue what might be going on here?


Code =

Gemini:

AppActivate ("CSM - Citrix Presentation Server Client")
SendKeys ("{^V}"), True

Kind regards,

Basta



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Sendkeys

Gary,

Found the issue s instead of S

:-S

"Gary''s Student" wrote:

If the problem is intermittent, it may be a timing issue. Try putting a
DoEvents between your statements
--
Gary''s Student - gsnu201002


"Basta1980" wrote:

Hi all,

I'm using a simple sendkey statement to paste (ctrl v) cell content to
another application. However when running the code it sometimes works (I can
see the cell content copied and pasted to the application) but most of the
times it just jumps from Excel to the other application and stops (so nothing
is pasted). Anybody got a clue what might be going on here?


Code =

Gemini:

AppActivate ("CSM - Citrix Presentation Server Client")
SendKeys ("{^V}"), True

Kind regards,

Basta

Reply
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 wangww Excel Programming 2 April 8th 10 11:02 AM
SendKeys Help ankur Excel Programming 2 January 17th 07 11:25 AM
Sendkeys Jim Excel Programming 1 April 16th 05 06:44 PM
SendKeys? CMK Excel Programming 2 February 23rd 05 12:03 AM
Sendkeys GB[_3_] Excel Programming 0 September 16th 03 10:39 PM


All times are GMT +1. The time now is 01:07 PM.

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

About Us

"It's about Microsoft Excel"