Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default What's the syntax error with this SendKeys code?

Why is it I can never understand the syntax mentioned in VBA Help?

I'm trying to use send keys at the moment and VBA help says as an example to
press Alt-F-X

Application.SendKeys("%fx")


So when I try and use Alt-F4 to exit WinAmp I type the code:

C:\Program Files\Winamp\winamp.exe.SendKeys("%{f4}")


and the moment I move to another line it comes up with the error message:
"Compile error: Expected: line number or statement or end of statement" and
it highlights the first "backslash \".

Judging from other code experts on this site have taught me, I would have
guessed "speach marks" should go around the path to the application, but that
doesn't work and VBA help doesn't suggest it.

Thanks in advance

Phil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What's the syntax error with this SendKeys code?

you wouldn't use winapp. You litterally use the word "Application" which
refers to Excel. Sendkeys sends the keystrokes to the active application
(the window with the focus). Just as a caution and it may not be an issue
for you, but If you do it right after a shell command, You might want need
to employ the WAIT command beforw sendkeys.



--
Regards,
Tom Ogilvy


"Phil1982" wrote in message
...
Why is it I can never understand the syntax mentioned in VBA Help?

I'm trying to use send keys at the moment and VBA help says as an example

to
press Alt-F-X

Application.SendKeys("%fx")


So when I try and use Alt-F4 to exit WinAmp I type the code:

C:\Program Files\Winamp\winamp.exe.SendKeys("%{f4}")


and the moment I move to another line it comes up with the error message:
"Compile error: Expected: line number or statement or end of statement"

and
it highlights the first "backslash \".

Judging from other code experts on this site have taught me, I would have
guessed "speach marks" should go around the path to the application, but

that
doesn't work and VBA help doesn't suggest it.

Thanks in advance

Phil



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SendKeys syntax problem VBAvirgin New Users to Excel 2 January 4th 06 04:42 PM
variable not declared error & syntax error G. Beard Excel Programming 1 October 6th 05 09:16 PM
Syntax Error in VLOOKUP Code Ken Excel Programming 3 October 20th 04 05:50 PM
help with code/syntax Jay Baxter Excel Programming 0 February 26th 04 08:11 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 06:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"