Solved

WScript.Shell and VBA

Posted on 2004-08-02
4
3,263 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
ID: 11694469
fsoFile.writeline "fso.SendKeys " & CStr(strMail) & ", True"
0
 

Author Comment

by:augstef
ID: 11694660
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
ID: 11694709
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
ID: 11694781
great...it's working...thanks a lot
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…

929 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