View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default SendKeys to open application

Arne,
"WaitFor" is not Excel/VBA. I suspect Access/VBA but not sure. One way is:
Application.Wait Now + TimeValue("0:00:01")

Also try removing the brackets from the appactivate statement.

SendKeys is always going to be doubtful IMHO.

NickHK

"Arne Hegefors" wrote in message
...
Hi! I try to open a program from a macro in Excel and login (the Bloomberg
professional, (not the website)) using SendKeys. With some help from

other
programmers I got the following code. It does not work at all though and I

am
lost. Can someone please help me with this? My problems a

1) I get error on the WaitFor .line. "Sub or Function has not been

defined"
2) If I delete the WairFor line I get error on the
AppActivate("1-BLOOMBERG") line. "Illegal procedure call or argument"


Sub bbg_login()
AppActivate("1-BLOOMBERG")
Application.SendKeys "{BREAK}",false
WaitFor timevalue("00:00:01")
Application.SendKeys "user_Name", false
Application.SendKeys "{TAB}", false
Application.SendKeys "password", false
Application.SendKeys "~", false
End Sub


Any help appreciated!