Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel
#1
OK, I am feeling really dumb but I am having a tough time figuring this out. I just cannot get it thru my thick head how to proceed.

All I am wanting to do, is reach out to an Excel spreadsheet and grab the text in cell A1 and enter it into a field in another program, hit enter, and repeat with the data in cell A2, and repeat going down the column in Excel until I run into an empty cell in Excel.

I realize this is probably very basic, but I just cannot get my hands around it.

TIA for any help! :?
#2
This macro repeatedly copies Excel cells from a single column, and pastes in Notepad. Starts from the selected cell.
Code:
Copy      Help
str s
rep
,act "Excel"
,s.getsel
,s.rtrim("[]")
,if(!s.len) break
,key D
,
,act "Notepad"
,s.setsel
,key Y

This macro does almost the same (gets all cels from column A and pastes in Notepad), but much faster. Needs at least QM 2.1.7.
Code:
Copy      Help
act "Notepad"
spe 0 ;;maximum speed
ARRAY(str) row
foreach row "" FE_ExcelRow
,row[0].setsel ;;gets cell from column A. To get from other columns, use 1, 2, etc.
,key Y

This macro transfers all columns, not only A. Needs at least QM 2.1.7.
Code:
Copy      Help
act "Notepad"
spe 0
ARRAY(str) row
int col
foreach row "" FE_ExcelRow
,for col 0 row.len
,,row[col].setsel
,,key T
,key Y
#3
Thanks Gintaras,
The second version is a LOT faster than the first! I tried to enhance this version to grab columns 'A', 'B', 'C' to fill in multiple fields. The code I tried (which does not work) was:

act "Notepad"
spe 0 ;;maximum speed
ARRAY(str) row
int column='A' ;;change this if you need other column
int column2='B'
int column3='C'
foreach row "" FE_ExcelRow
,key "*"; key T
,row[column-'A'].setsel
,key T; key T
,row[column2-'B'].setsel
,key T
,row[column3-'C'].setsel
,key Y

I think I am getting closer. Unfortunately, the value in column 'A' gets placed in all three fields in notepad rather than the unique data from columns 'A', 'B', 'C'.

Thanks again for the help.
#4
I confused you with column-'A'. Simply use 0 for A, 1 for B, and so on.

Code:
Copy      Help
act "Notepad"
spe 0 ;;maximum speed
ARRAY(str) row
foreach row "" FE_ExcelRow
,key "*" T
,row[0].setsel
,key TT
,row[1].setsel
,key T
,row[2].setsel
,key Y


Forum Jump:


Users browsing this thread: 1 Guest(s)