JonnnyExcel
New Member
- Joined
- Feb 9, 2011
- Messages
- 8
Thank you for the great forum to ask questions and get answers. I have used it many times to help out with Excel problems.
I am trying to write VBA code in Excel 2007 to open (I have that part figured out) and then access the Tools menu, enter and start a data acquisition by “clicking” the Execute button of a non Office/Microsoft program that is collecting data from a sensor controller. The program responds to short cut keys (Alt+T, enter and then Alt+E). I have tried using SendKeys, also understand that this is not a robust way to do this, and can’t get it to work. Below is some of the code I have tried.
I have tried in place of Application SendKeys declaring for example AltKey As String and then using SendKeys AltKey. I believe that it maybe a problem of focus, the program is not the focus so the code doesn’t know where to send the “keys” to. I can’t figure out how to make the focus this non Office program.
Any and all help would be much appreciated. I will need this to be robust as it will be on our manufacturing floor in use with people who don’t really understand computers that well.
Thank you and looking forward to your help.
I am trying to write VBA code in Excel 2007 to open (I have that part figured out) and then access the Tools menu, enter and start a data acquisition by “clicking” the Execute button of a non Office/Microsoft program that is collecting data from a sensor controller. The program responds to short cut keys (Alt+T, enter and then Alt+E). I have tried using SendKeys, also understand that this is not a robust way to do this, and can’t get it to work. Below is some of the code I have tried.
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]'Access Tools Menu[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Application.SendKeys "{%}t"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]' delay 1 sec[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Application.Wait Now + TimeValue("00:00:01")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]'Enter[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Application.SendKeys "{~}"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]'delay 5 sec to allow program to respond[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Application.Wait Now + TimeValue("00:00:05")[/COLOR][/SIZE][/FONT]
Any and all help would be much appreciated. I will need this to be robust as it will be on our manufacturing floor in use with people who don’t really understand computers that well.
Thank you and looking forward to your help.