Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default appactivate sendkeys not working with accelerator

Using Excel 2002.
Have a simple sub that picks up a value from the active sheet, activates
another application and sends the value to the application. This sub runs
through a command button on a userform.
When I click the command button all works fine.
The command button has an accelerator key in this "z".
When I do Alt + z the application gets activated but the values don't get
send.

The simplified sub goes like this. The application is not actually
Calculator, but this sub shows the same behaviour.

Sub Test()

Dim ID As String

ID = ActiveCell.value

AppActivate "Calculator", True 'tried False as well

SendKeys ID, True

End Sub

When I put MsgBox ID before the line AppActivate it works again with the
accelerator key strokes.
It seems this problem has to do with focus, but I can't see the solution.
Thanks for any advice.


RBS


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default appactivate sendkeys not working with accelerator

I think you've oversimplified it now <G.

Sometimes including a line

Doevents

solves these issues as it gives some time for various handlers to do what
they wanna do....

give it a try and let us know



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"RB Smissaert" wrote:

Using Excel 2002.
Have a simple sub that picks up a value from the active sheet, activates
another application and sends the value to the application. This sub

runs
through a command button on a userform.
When I click the command button all works fine.
The command button has an accelerator key in this "z".
When I do Alt + z the application gets activated but the values don't

get
send.

The simplified sub goes like this. The application is not actually
Calculator, but this sub shows the same behaviour.

Sub Test()

Dim ID As String

ID = ActiveCell.value

AppActivate "Calculator", True 'tried False as well

SendKeys ID, True

End Sub

When I put MsgBox ID before the line AppActivate it works again with the
accelerator key strokes.
It seems this problem has to do with focus, but I can't see the

solution.
Thanks for any advice.


RBS




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default appactivate sendkeys not working with accelerator

Sub Test()
Dim ID As String
ID = "123{+}456="
AppActivate "Calculator", True 'tried False as well
SendKeys ID, True
End Sub


worked fine for me with the calculator.

--
Regards,
Tom Ogilvy

"RB Smissaert" wrote in message
...
Using Excel 2002.
Have a simple sub that picks up a value from the active sheet, activates
another application and sends the value to the application. This sub runs
through a command button on a userform.
When I click the command button all works fine.
The command button has an accelerator key in this "z".
When I do Alt + z the application gets activated but the values don't get
send.

The simplified sub goes like this. The application is not actually
Calculator, but this sub shows the same behaviour.

Sub Test()

Dim ID As String

ID = ActiveCell.value

AppActivate "Calculator", True 'tried False as well

SendKeys ID, True

End Sub

When I put MsgBox ID before the line AppActivate it works again with the
accelerator key strokes.
It seems this problem has to do with focus, but I can't see the solution.
Thanks for any advice.


RBS




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default appactivate sendkeys not working with accelerator

Tom, Keepitcool,


Did you run this sub from a UserForm via an accelerator key connected to a
command button?
That is the situation I was talking about.
Managed to improve it by putting in 3 DoEvents like this:

Sub Test()

Dim ID As String

ID = ActiveCell.value

DoEvents

AppActivate "Calculator", True

DoEvents

SendKeys ID, True

DoEvents

End Sub


Even then it doesn't always work.
Would there be any alternative to using SendKeys?


RBS




"Tom Ogilvy" wrote in message
...
Sub Test()
Dim ID As String
ID = "123{+}456="
AppActivate "Calculator", True 'tried False as well
SendKeys ID, True
End Sub


worked fine for me with the calculator.

--
Regards,
Tom Ogilvy

"RB Smissaert" wrote in message
...
Using Excel 2002.
Have a simple sub that picks up a value from the active sheet, activates
another application and sends the value to the application. This sub

runs
through a command button on a userform.
When I click the command button all works fine.
The command button has an accelerator key in this "z".
When I do Alt + z the application gets activated but the values don't

get
send.

The simplified sub goes like this. The application is not actually
Calculator, but this sub shows the same behaviour.

Sub Test()

Dim ID As String

ID = ActiveCell.value

AppActivate "Calculator", True 'tried False as well

SendKeys ID, True

End Sub

When I put MsgBox ID before the line AppActivate it works again with the
accelerator key strokes.
It seems this problem has to do with focus, but I can't see the

solution.
Thanks for any advice.


RBS





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default appactivate sendkeys not working with accelerator

Thanks. Perhaps there lies the difference. My UserForm is a modeless
UserForm.

RBS


"Tom Ogilvy" wrote in message
...
Yes, I ran it using an accelorator key while the userform was displayed
modally

Worked fine:

Private Sub CommandButton1_Click()

Dim ID As String
ID = "123{+}456="
AppActivate "Calculator", True 'tried False as well
SendKeys ID, True


End Sub

--
Regards,
Tom Ogilvy

"RB Smissaert" wrote in message
...
Tom, Keepitcool,


Did you run this sub from a UserForm via an accelerator key connected to

a
command button?
That is the situation I was talking about.
Managed to improve it by putting in 3 DoEvents like this:

Sub Test()

Dim ID As String

ID = ActiveCell.value

DoEvents

AppActivate "Calculator", True

DoEvents

SendKeys ID, True

DoEvents

End Sub


Even then it doesn't always work.
Would there be any alternative to using SendKeys?


RBS




"Tom Ogilvy" wrote in message
...
Sub Test()
Dim ID As String
ID = "123{+}456="
AppActivate "Calculator", True 'tried False as well
SendKeys ID, True
End Sub


worked fine for me with the calculator.

--
Regards,
Tom Ogilvy

"RB Smissaert" wrote in message
...
Using Excel 2002.
Have a simple sub that picks up a value from the active sheet,

activates
another application and sends the value to the application. This sub

runs
through a command button on a userform.
When I click the command button all works fine.
The command button has an accelerator key in this "z".
When I do Alt + z the application gets activated but the values

don't
get
send.

The simplified sub goes like this. The application is not actually
Calculator, but this sub shows the same behaviour.

Sub Test()

Dim ID As String

ID = ActiveCell.value

AppActivate "Calculator", True 'tried False as well

SendKeys ID, True

End Sub

When I put MsgBox ID before the line AppActivate it works again with

the
accelerator key strokes.
It seems this problem has to do with focus, but I can't see the

solution.
Thanks for any advice.


RBS








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 string hawki Excel Discussion (Misc queries) 4 May 11th 07 08:30 PM
Can I assign a keyboard accelerator for Paste Special/Transpose? RedmoatACG Excel Discussion (Misc queries) 0 March 30th 06 07:31 PM
SendKeys syntax problem VBAvirgin New Users to Excel 2 January 4th 06 04:42 PM
SendKeys function moglione1 Excel Discussion (Misc queries) 1 November 7th 05 02:57 PM
sendkeys mark poole Excel Programming 0 July 11th 03 03:47 PM


All times are GMT +1. The time now is 01:46 AM.

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"