ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Interaction and SendKeys (https://www.excelbanter.com/excel-programming/408805-interaction-sendkeys.html)

Albert

Interaction and SendKeys
 
Hello.
I use an econometric program called Stata.
I want a procedure that sends a command to Stata's Command Window.
I have created one but it works sporadically. Perhaps someone has some
suggestions? Maybe an option that does not involve SendKeys?
Here's the code I'm using.

Dim ReturnValue
ReturnValue = Shell("C:\Stata9\wsestata.exe", vbMaximizedFocus)
VBA.Interaction.AppActivate ReturnValue, True
Application.SendKeys "This is the command to send to Stata"

Thanks!
Albert C

Jim Thomlinson

Interaction and SendKeys
 
Using send keys is generally unreliable. Does Stata have an API allowing you
to interface with the program?
--
HTH...

Jim Thomlinson


"Albert" wrote:

Hello.
I use an econometric program called Stata.
I want a procedure that sends a command to Stata's Command Window.
I have created one but it works sporadically. Perhaps someone has some
suggestions? Maybe an option that does not involve SendKeys?
Here's the code I'm using.

Dim ReturnValue
ReturnValue = Shell("C:\Stata9\wsestata.exe", vbMaximizedFocus)
VBA.Interaction.AppActivate ReturnValue, True
Application.SendKeys "This is the command to send to Stata"

Thanks!
Albert C


Albert

Interaction and SendKeys
 
Hello Jim.
Unfortunately I've found no DLL or API. There is only a .exe, but when I try
to make the reference in VBA, I get a "Can't make reference to that file"
message.


"Jim Thomlinson" wrote:

Using send keys is generally unreliable. Does Stata have an API allowing you
to interface with the program?
--
HTH...

Jim Thomlinson


"Albert" wrote:

Hello.
I use an econometric program called Stata.
I want a procedure that sends a command to Stata's Command Window.
I have created one but it works sporadically. Perhaps someone has some
suggestions? Maybe an option that does not involve SendKeys?
Here's the code I'm using.

Dim ReturnValue
ReturnValue = Shell("C:\Stata9\wsestata.exe", vbMaximizedFocus)
VBA.Interaction.AppActivate ReturnValue, True
Application.SendKeys "This is the command to send to Stata"

Thanks!
Albert C



All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com