PDA

View Full Version : Sendkeys in vba macros



jsanraj
04-20-2010, 07:55 AM
Hi, I need the code to do sendkey operations in msword macro to activate other application and perform some paste action. Please give worked sample for sendkey operations.

johnkubik
04-20-2010, 08:03 AM
Try this.

I just copied and pasted this from joms in a thread about 3 threads ago. He hasn't tested it and neither have I. Hope this helps.

SendKeys "^%b", True

fumei
04-20-2010, 10:12 AM
And have you looked up SendKeys in Help?

Paul_Hossler
04-20-2010, 07:47 PM
In my test, I had Test123.txt open in Notepad, ran the little macro to activate the Notepad window, write some text, then return to the word document, and write some more



Sub drv()
Call AppActivate("Test123", False)
Call SendKeys("Now is the time, etc.", True)
Call AppActivate("Test_AppActivate", False)
Call SendKeys("The quick brown fox, etc.", True)

End Sub


Paul