Computing.Net > Forums > Programming > .sendkeys variable in VBS

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

.sendkeys variable in VBS

Reply to Message Icon

Name: Chris Crash
Date: July 6, 2009 at 08:58:01 Pacific
OS: Windows Vista
Subcategory: General
Comment:

I am working on a small VBS script that is *supposed* to enter a user defined variable into excel. What happens istead is that it opens excel and then says there is a problem. When I did not put a variable in, it typed the word in. I need to no how to make the shellobj.sendkeys command work with variables. Here is my code:

DIM userInput
set shellobj = CreateObject("WScript.Shell")
name = inputbox("Please Enter Your Name")
shellobj.run "cmd"
wscript.sleep 500
shellobj.sendkeys "start excel.exe{enter}exit{enter}"
wscript.sleep 3000
shellobj.sendkeys "{& name &}{enter}"

the error message that pops up says
Line: 8
Char: 1
Error: invalid procedure call or argument.

But when I change the shellobj.senkeys "{& name &}{enter}" to shellobj.senkeys "john{enter}" , it works. Please help.



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 7, 2009 at 20:23:14 Pacific
Reply:

To quote the documentation, "To send brace characters, send the string argument '{{}' for the left brace and '{}}' for the right one."


0

Response Number 2
Name: Chris Crash
Date: July 8, 2009 at 08:06:35 Pacific
Reply:

Thanks, that was just what I needed! I am also curious how you send the + symbol using .sendkeys command.

shellobj.sendkeys " + "

This script I am using doesn't work.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


java chat rooms Mkdri & Move



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: .sendkeys variable in VBS

System Environment Variables in VB www.computing.net/answers/programming/system-environment-variables-in-vb/12819.html

setting environment variables in vb www.computing.net/answers/programming/setting-environment-variables-in-vb/13145.html

Declaring Variables in VB 6.0 www.computing.net/answers/programming/declaring-variables-in-vb-60/9957.html