Solved

WScript.Shell and VBA

Posted on 2004-08-02
4
3,252 Views
Last Modified: 2012-06-21
Hi, I have the following script

Dim strMail As String
strMail = "MYNEWNAME"

Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.createtextfile("ByTest.vbs")
fsoFile.writeline "set fso = createobject(""WScript.Shell"")"
fsoFile.writeline "wscript.sleep 5000"
fsoFile.writeline "fso.SendKeys ""{TAB}"", True"
fsoFile.writeline "fso.SendKeys ""{TAB}"", True"
fsoFile.writeline "fso.SendKeys ""{TAB}"", True"
fsoFile.writeline "fso.SendKeys CStr(strMail), True"
fsoFile.Close

this script is working w/o 'fsoFile.writeline "fso.SendKeys CStr(strMail), True" ' . How can I pass the value of the strMail variable in vbs script? I have to mention that just for test purpose the value of strMail is like now, otherwise it is store in Access table.

thanks,
augstef
0
Comment
Question by:augstef
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:jmacmicking
Comment Utility
fsoFile.writeline "fso.SendKeys " & CStr(strMail) & ", True"
0
 

Author Comment

by:augstef
Comment Utility
the strMail has to be in vbs file in this format "MYNEWNAME" and isn't and it's required to be able to use it as sendkeys
0
 
LVL 5

Accepted Solution

by:
jmacmicking earned 50 total points
Comment Utility
Sorry,
fsoFile.writeline "fso.SendKeys """ & CStr(strMail) & """, True"
Use double quotes to indicate a single quote in the destination string.
0
 

Author Comment

by:augstef
Comment Utility
great...it's working...thanks a lot
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now