That's a tough task to fully automate. One thing that would help greatly is if you can set the document up as a Word form.
That page explains how it works. You lay out your document as you like, and wherever you have variables to insert, insert a text box. Then protect the document, close it, and open it. Now pressing Tab only takes you from field to field. Here's a stupid dummy form I made using some placeholder text:
Word test form
When you open a form document, the first field is selected, and only fields can be selected, so Tab or Right Arrow moves between them.
With the form in place, I would then get rid of your Keyboard Maestro multi-variable input form (you're the only user of the macro, right?), which requires a lot of tedious copy-and-paste work, back and forth, and waiting on Word's Replace All to show up.
Instead, if you're using Keyboard Maestro version 11, I'd gather my input using the Prompt for Snippet action:
This creates an input box where you tab to each field and enter the values:
You might wonder about the underscores. I used those because Prompt for Snippet returns not just your input, but also the labels for those inputs. You could have no labels, but that would be confusing. By using two underscores (or any other characters that aren't likely to show up in your actual text), I can strip the labels out with a regex search.
Say I filled out my form as shown above; the local_theInput
variable would now hold all six lines of my input:
ABC
DEF
GHI
JKL
MNO
PQR
The remainder of the macro then becomes incredibly simple: All it does is activate Word, then loop through the lines in the local_theInput
variable, pasting each into a field then pressing the right arrow:
You'll notice a disabled Pause action there; it wasn't needed on my Mac, but if yours won't keep up with the field hopping and pasting, enable it and change it as necessary.
I have attached the above sample macro, as well as the Word form document I used to test it with. You'll want to read up on forms, as they're just a bit tricky (you create them with the document unprotected, then protect it, save it, close it, and reopen it to test), but not overly complicated. You have to have the Developer toolbar item showing, but the Microsoft link above explains how to do that.
_Word Form Test.kmmacros (4.7 KB)
Word form test.zip (11.8 KB)
If you don't have Keyboard Maestro 11, you can do something similar though it's trickier to get the multi-line input into one variable. If you'd like that solution, let me know and I'll see if I can put it together.
Hope this helps!
-rob.
EDIT: Accidentally uploaded just one action from the macro the first time; corrected now.