Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy Data From Excel and Key It In Other Program
#1
I have a repetitive daily task where I take data from Excel and type it into another program we use at work. Unfortunately I can't simply copy and paste the data because the other program uses drop down menus to select the numbers. I did search and find another thread with a similar question and used some script from there:

 get selected cells in Excel
ExcelSheet es.Init
ARRAY(str) a
es.CellsToArray(a "sel")

 type first selected column in Notepad
act "Notepad" ;;activate window
spe 20 ;;speed
act(win("Hour Moves - Google Chrome" "Chrome_WidgetWin_1"))
int row
for row 0 a.len
    key (a[0 row]) Y ;;type cell and press Enter
act(win("Transfer Hours - Excel" "XLMAIN"))
'T            ;; Tab 


It did work to input the first number, but I was trying to figure out how to do multiple sets of numbers and repeat until it runs into a blank cell. Here is the Excel sheet:
   

And here is where it would be keyed into:

   

You just press Enter to move between each dropdown menu. Any advise would be appreciated, thanks!
#2
this will get all cells in all rows
the first for loop starts on 1 instead of 0 since we don't need row 1 in this case
Code:
Copy      Help
ExcelSheet es.Init
ARRAY(str) a
int r c
es.CellsToArray(a "" 3)
out "---- all ----"
for r 1 a.len
,for c 0 a.len(1)
,,out "--row-- %i  --col-- %i" r+1 c
,,out a[c r]

this will get all the cells of a row
Code:
Copy      Help
ExcelSheet es.Init
ARRAY(str) a
int r c 
int row=2;; change this number to a specifc row
,es.CellsToArray(a ExcelRow(row) 3)
,out "---- row %i ----" row
,for c 0 a.len(1) ;;for each column
,,out a[c 0]

You should be able to work out your next move with one of these . If not come back and someone should be able to help.
#3
Thanks for the reply. I see that it copies the data, but it isn't quite what I was trying to do. I also didn't do an adequate job explaining the process I use when manually performing the task. If W1=Excel and W2=the Hour Moves program, what I would do is:

Start at A2 in W1, Copy
Alt-Tab to W2 with the cursor in the Associate Number drop down, have QM "key" the copied data
press Enter
Alt-Tab back to W1, Tab, Copy, and repeat the process.
I would do that for the four columns in row 2, then start in cell A3 and repeat everything until it runs into a blank cell since the number of entries needed is different everyday.

Thanks for the help


Forum Jump:


Users browsing this thread: 1 Guest(s)