Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sendkey and dangers

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
Hello,

Can I confirm that if you use sendkey in the vba macro, if you change the focus onto another (say Outlook) sendkey sends the keystrokes to the other application?

Thanks in advance,
R
Chris
 
SendKeys sends the keystrokes to the ACTIVE window.
You may consider the AppActivate method as a companion for SendKeys.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
you can code outlook using vba just like you can in excel, you should be able to get a reference to outlook and move data around that way
 
mrmovie, the SendKeys method may be used to workaround the outlook object model guard issue.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I would suggest avoiding the Sendkey command just because it can cause unpredictable results. Your absolutely right (PH) in the fact that the Active window will accept the keystrokes, even if its not the intended target.

I think of the Sendkey command as if someone is sitting in front of the keyboard and pressing keys ....... but is BLINDFOLDED! Just try and move around some applications without using your eyes!?!

Using VB within the office suite usually has a better and more controlled way of making something happen (mrmovie is spot on). There is exceptions to this rule, like what PH has suggested about the Outlook security features.

Avoid at all costs and only use as a last resort is my advice.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top