I am trying to create a VBScript that inserts some text from the clipboard into an existing (and loaded) Word document. I have tried numerous approaches without success (including Selection.Paste) but Word (2013) will just not paste. Whilst trying to diagnose the problem, I have got down to this minimal script.
Set objWord = GetObject(, "Word.Application")
objWord.Application.Activate
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.SendKeys "Arggh 1"
objShell.SendKeys "^V"
objShell.SendKeys "Arggh 2"
If I place some text on clipboard (I have got down to basic unformatted text, I originally started with MathML but that is another story), the above script generates
Arggh 1Arggh 2
with the text left on the clipboard. If I then press Ctrl+V, the clipboard text gets pasted as expected.
I feel like I am missing something obvious. Any help most welcome.