...but now understand it to mean:
"I generally don't like the idea of [using AHK commands to] send keystrokes (or mouse clicks) [in] Excel (or Word)." Is that correct?
Yes!
they so precisely duplicate the manual keystrokes
Yes, and that's both the good news and the bad news.
yet you are enthusiastic about replacing them
Indeed, I am! One problem with sending keystrokes is that they can get out of kilter and start going berserk. For example, I was trying to help a user who was sending mouse clicks and keystrokes with AHK. But during my testing, the focus window changed unexpectedly due to an external event, and all of a sudden mouse clicks and keystrokes — including the Delete key — were being sent to my file manager — scared the dickens out of me! I wound up completely rewriting the script with AHK COM calls.
Another problem is performance. Keystrokes are often sent too fast, and you'll frequently see the recommendation to put in Sleep commands to give the cursor time to land where it's supposed to be before sending the next keystroke. I've seen recommendations for sleep times as low as 50 milliseconds and up to several seconds. Those Sleep commands can add up to painful performance. In the script that I mentioned above, I was literally watching the cursor move down the A column to its end, then across to the top of the B column, then down the B column to its end, then across to the top of the C column, etc. Of course, there were Sleep commands all along the way — very painful to watch. I replaced all of that with a Loop command on the rows followed by a Loop command on the columns and COM calls inside the loop like this:
CurrentCell:=CurrentColumn . CurrentRow
ExcelCells[CurrentColumn,CurrentRow]:=oWorkbook.Worksheets(1).Range(CurrentCell).Value
Much more reliable and much faster!
AHK can commonly — maybe always, I don't know — be used in place of VBA in MS Office apps
Yes, and, in my experience, more reliably. For example, in another EE thread, the asker was trying to run a VBA macro that counted words in a DOC/DOCX file. It worked fine on a small doc, but on a large one (
War and Peace — more than a half-million words), there was no progress (nothing in the status bar) after about five minutes. It seemed to be hanging, and then I got a VBA error dialog box that said "Run-time error '28': Out of stack space". I wrote an AHK script to do it, making Word COM calls, and it takes 72 seconds to process
War and Peace — all 567,919 words — no problems, no errors. Of course, that's just one example, and it may have been due to a poorly written VBA macro. All I can say is that AHK's COM calls have always worked very well for me. Regards, Joe