ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   sendkey help needed (https://www.excelbanter.com/excel-discussion-misc-queries/117580-sendkey-help-needed.html)

Ryk

sendkey help needed
 
I have a project where I need to interact with a program and grab data.

I can make it grab it once, but have to reset it to do a second one,
and I think its because I don't know how to make a send key tab one
backwards.

I have a column of numbers in A, I tab to next screen, and the first
cell is where I need drop the data, then I tab once, and hit enter to
get my needed info. I am making no headway with this, but here is what
I have tried....

Sub GetData()
Dim Data As String
Data = ActiveCell.Value
' go down a row
ActiveCell.Offset(1, 0).Select
' flip back to previous window
SendKeys "%{tab}", True
' enter the Data
SendKeys Data, True
SendKeys "{tab}", True
' send it
SendKeys "{enter}", True
' need next line to tab back to last cell (not working)
SendKeys "{tab}", True
SendKeys "%{tab}", True
End Sub


For some reason it repeats the data it first grabbed over and over.

Thanks for any help.

Dave


Ryk

sendkey help needed
 
Secondary question, what sendkey command does select all, copy etc? Is
there a list of sendkey commands somewhere?

Dave


Héctor Miguel

sendkey help needed
 
hi, Ryk !

Secondary question, what sendkey command does select all, copy etc?
Is there a list of sendkey commands somewhere?


your previously posted code [with minor corrections -uppercase-] is working [for me] as follows:

Sub GetData()
Dim Data As String
Data = ActiveCell.Value ' ANY NUMBER
' go down a row
ActiveCell.Offset(1, 0).Select
' flip back to previous window [THE CALCULATOR]
SendKeys "%{tab}", True
' enter the Data AND MULTIPLY IT BY 5
SendKeys Data & "*5{enter}", True
' get result
SendKeys "^c", True
' need next line to {ALT} tab back to last cell (IS working NOW)
SendKeys "%{tab}", True
' paste calculator result
SendKeys "^v{esc}"
End Sub

hth,
hector.



Ryk

sendkey help needed
 

Héctor Miguel wrote:
hi, Ryk !

Secondary question, what sendkey command does select all, copy etc?
Is there a list of sendkey commands somewhere?


your previously posted code [with minor corrections -uppercase-] is working [for me] as follows:

Sub GetData()
Dim Data As String
Data = ActiveCell.Value ' ANY NUMBER
' go down a row
ActiveCell.Offset(1, 0).Select
' flip back to previous window [THE CALCULATOR]
SendKeys "%{tab}", True
' enter the Data AND MULTIPLY IT BY 5
SendKeys Data & "*5{enter}", True
' get result
SendKeys "^c", True
' need next line to {ALT} tab back to last cell (IS working NOW)
SendKeys "%{tab}", True
' paste calculator result
SendKeys "^v{esc}"
End Sub

hth,
hector.


This is interesting as I read it, but I am unsure now how to change it
to fit, you see the data window has 2 tab stops, one to enter data,
then if I tab over and hit enter on a Run Data button, it processes the
info, (unlike calculator, with one cell) the problem is I do not know
how to make it tab back to the first cell, so I can re-run the macro
with new data. The calculator thing does work well, and I can use this
on another project i am sure, but for this one the tab to the left is
needed. I also dearly need a "copy all" for this, because the data,
when returned is in a list, and if I copy the sheet (external data
sheet) and paste to a blank excel sheet, the data I need is always in
same cell. My plan was this, copy the sheet, move it to blank sheet,
copy that cell, enter that on my Data sheet, delete the blank sheet,
and loop this. On my (sheet 1) the info I work this is column A, so
grab data (sheet 1) A1, flip to (external data sheet), paste (in first
cell), tab right hit enter, copy the (external data sheet), tab back
one left(to be ready for next loop), flip to excel blank excel
sheet(lets call it Sheet 2), paste, grab data from (Sheet 2) D14, move
back to (sheet 1), move one cell right. paste data, offset back to A
but down one row, clear data from (Sheet 2), and be ready to start it
all over. But as the external data sheet is not windows or excel, the
send keys have to be used in this. Hector, I hope this helps explain
better.

Dave


Ryk

sendkey help needed
 

Seems I also need to clear the first cell in the external page, before
I paste data to it, it doesn't allow copy over?

Dave



All times are GMT +1. The time now is 12:25 PM.

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