1
votes

I got some help yesterday about using a loop to copy data down an SAP column to transfer the data over to excel. I was able to get it copying and moving down the column, however it now stops copying (error 619 can not find ID) when it reaches the bottom of my screen. I assume it is because it cannot "see" the values anymore but I was wondering if anyone knew a work around. Here is the relevant code I have so far. Note: i starts at 16 because of how the script is recording the position of the fields. It starts at 16 and moves up by 1 from there.

'Copy Number of Batches in Column
Number_of_Batches = session.findById("wnd[0]/usr/lbl[74,13]").Text
session.findById("wnd[0]/usr/lbl[74,13]").caretPosition = 5

'Variable for copying down the SAP Column
For i = 16 To Number_of_Batches + 15

'Loops through each bactch for the material code
'Do

'**** Must convert to a string here****
'Copy down SAP column
session.findById("wnd[0]").maximize
Current_Batch = session.findById("wnd[0]/usr/lbl[12," & CStr(i) & "]").Text
session.findById("wnd[0]/usr/lbl[12," & CStr(i) & "]").caretPosition = 6
session.findById("wnd[0]").sendVKey 0

'Pastes to all SAP Batches Column
Cells(Z, 10) = Current_Batch

Z = Z + 1

Next i
1

1 Answers

0
votes

Add a

session.findById("wnd[0]/usr/lbl[12," & CStr(i) & "]").setFocus

This might not be neccessary for each line, so you could set the focus every 10th step.