I have data in this form which I’d like to enter into our accounting software without doing it manually:
ItemNumber. Quantity
When doing it manually, ItemNumber is the first field. The user then enters TAB and the Quantity field is selected. One more TAB takes one to the next line of data entry.
I’m now 78 years old and haven’t tried to program in KM for years. Whatever skills I used to have are in a sorry state which is why I’m here hoping for help. (Thanks in advance!)
I’ve found the “for each” action which looks like it might do what I want with some revision.
Question:
Can a collection include more than one field, and is there any way to embed a tab command between the fields? I’m trying to automate the manual entry sequence described above so that KM would go to the first field, copy the ItemNumber, paste it into the ItemNumber box in our accounting software, tab to the Quantity box, paste in the quantity, and then tab once more so it’s ready to repeat with the next line in the collection.
Suggestions greatly appreciated and assume I’m not very agile with coding.
Is this just one item or a number of lines in that format? Is the data from a file, some Copied text, something else? Are ItemNumber and Quantity separated by <period><space> as you've written?
You only need the "For Each" if you are handling multi-line input -- although it will also work for multi-line input that only contains one line
Assuming that the separator is indeed . and that doesn't occur anywhere else in the line, you use that as your "pseudo array item delimiter". For input that you've Copied to the System Clipboard
For Each line on the System Clipboard
Paste the first array item of the line
Simulate Tab
Paste the second array item of the line
Simulate Tab
End For Each
The Pauses are to stop your macro from running ahead of the UI -- they also let you see what's happening while troubleshooting. You can reduce them once you're happy with the macro.
The data could be from a text file or copied onto the clipboard.
The period space is software ‘helping’ (sigh). Correct format would be:
ItemNumber[TAB]Quantity[TAB]
The tabs need to be real keystrokes so that the accounting software will move to the next input box.
So the action as you’ve written it (with the item delimiter replaced with commas or something else) would pick up both the item numbers and the quantities before moving to the next line? I’ll give it a try and see if I have any luck. Thanks!
In KM's pseudo array notation, the number in the [ ] is the element number and the text between ] and % is the text you want to use as your item delimiter. So replace the . with \t -- the "escape code" for a tab, and more easily seen here and in the Editor than an actual Tab character (which will also work).