Solved

vbscript unknown charactor in sendkey

Posted on 2009-07-16
5
291 Views
Last Modified: 2012-05-07
I have, objShell.SendKeys name
I am getting name from a client access screen from an i Series.  If the text is just text everthing is cool, if I have a strang charactor, ( or + it errors out.  can I enclose the name in quotes or something to prevent this?  so something like objShell.SendKeys ' & name & '?
0
Comment
Question by:bergertime
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:solomonacquah
ID: 24870485
Where is sendkeys sending the information to a command line?
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 24870530
You could filter out any undesired characters from the string using a function like the one below.


strSample = "This is **#$a p*er\fe+ctly ordinary s%enten~ce."
strAllowed = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
 
WScript.Echo FilterChars(strSample, strAllowed)
 
Function FilterChars(strText, strFilter)
    For i = 1 to Len(strText)
        strChar = Mid(strText, i, 1)
        
        If InStr(strAllowed, strChar) > 0 Then
            strNewText = strNewText & strChar
        End If    
    Next
    
    FilterChars = strNewText
End Function

Open in new window

0
 
LVL 2

Author Comment

by:bergertime
ID: 24870538
To a windows app.  The script starts a clickonce app, then scraps the text from an as400, then pastes the text in the windows app.
0
 
LVL 4

Expert Comment

by:solomonacquah
ID: 24870584
Try using double quotes

objShell.SendKeys Chr(34) & name & Chr(34)
0
 
LVL 2

Author Closing Comment

by:bergertime
ID: 31604271
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Installer (VBSCRIPT) Rename Printer 3 57
Everything left of comma in excel 4 51
Button function on table is in trouble 3 41
Index Match Formula VBA 6 82
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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