Hi,
I am trying to write out an array of string variables to Notepad. I
can't get SendKeys to accept the string variable only literal quoted
strings.
I DO NOT want the hassle of writing to a file
I DO NOT want to write to a report
I DO NOT want to write to a form
My user requires I write this array of string variables out to Notepad,
and that I leave Notepad open. (They will be copying these strings and
pasting them into another application)
I tried three quotes and then the variable, but that didn't work
Dim strMyString As String 'Just one string I know
strMyString = "This is a string I want to output to Notepad"
'Then I opened notepad
SendKeys """ & strMyString & """ 'This doesn't work
Ahhhh.... Why is something so simple SO HARD
Any help is GREATLY appreciated
Vmusic 11 16177
Vmusic wrote: Ahhhh.... Why is something so simple SO HARD
Because it's incredibly stupid?
This works for me:
Sub TestSendKeys()
Dim s As String
s = "A dumb thing to do."
SendKeys """" & s & """"
End Sub
Dr Ju Chao
Dip Ed, BSci BCom, PHD
On 17 Mar 2006 21:21:45 -0800, "Lyle Fairfield" <ly***********@aim.com> wrote: Vmusic wrote:
Ahhhh.... Why is something so simple SO HARD
Because it's incredibly stupid?
No, some stupid things are quite easy to do as I have often discovered.
"JuChao" <jc******@hotmail.com> wrote in
news:11*********************@z34g2000cwc.googlegro ups.com: This works for me:
Sub TestSendKeys() Dim s As String s = "A dumb thing to do." SendKeys """" & s & """" End Sub
Dr Ju Chao Dip Ed, BSci BCom, PHD
Using sendkeys like in this example is incredibly dangerous.
--
Bob Quintal
PA is y I've altered my email address. My user requires I write this array of string variables out to Notepad<<
I'm not sure what you mean by array.
Maybe this will work and you don't need Sendkeys.
Public Sub Write_to_Text_File()
Dim strOne As String
Dim strTwo As String
Dim strThree As String
Dim RetVal
strOne = "I DO NOT want the hassle of writing to a file"
strTwo = "I DO NOT want to write to a report"
strThree = "I DO NOT want to write to a form"
Open "C:\MyFile.txt" For Output As #1 ' Open file for output.
''Write on separate lines
Write #1, strOne ' Write delimited data.
Write #1, strTwo
Write #1, strThree
''OR Write on one line as comma-delimited data
Write #1, ' Write blank line.
Write #1, ' Write blank line.
Write #1, strOne, strTwo, strThree
Close #1 ' Close file.
RetVal = Shell("C:\WINDOWS\Notepad.EXE C:\MyFile.txt", 1)
End Sub
Rick
Vmusic wrote: Hi, I am trying to write out an array of string variables to Notepad. I can't get SendKeys to accept the string variable only literal quoted strings.
I DO NOT want the hassle of writing to a file I DO NOT want to write to a report I DO NOT want to write to a form
My user requires I write this array of string variables out to Notepad, and that I leave Notepad open. (They will be copying these strings and pasting them into another application)
I tried three quotes and then the variable, but that didn't work
Dim strMyString As String 'Just one string I know strMyString = "This is a string I want to output to Notepad"
'Then I opened notepad SendKeys """ & strMyString & """ 'This doesn't work
Ahhhh.... Why is something so simple SO HARD
Any help is GREATLY appreciated Vmusic
Business requirements aren't necessarily stupid.
Thank you Dr. Chao for your consideration, however your function adds
an extra quote character. I want to send ONLY the characters from the
variable. Your procedure below sends an additional begining and ending
quote
Sub TestSendKeys()
Dim s As String
s = "A dumb thing to do."
SendKeys """" & s & """"
End Sub
"Vmusic" <ak*****@irisicom.net> wrote in
news:11*********************@g10g2000cwb.googlegro ups.com: Business requirements aren't necessarily stupid.
Nobody said that was the case. What is stupid is a programmer-
analyst who says "I dont want the hassle of writing to a file." Thank you Dr. Chao for your consideration, however your function adds an extra quote character. I want to send ONLY the characters from the variable. Your procedure below sends an additional begining and ending quote
Sub TestSendKeys() Dim s As String s = "A dumb thing to do." SendKeys """" & s & """" End Sub
--
Bob Quintal
PA is y I've altered my email address.
Vmusic wrote: I want to send ONLY the characters from the variable. Your procedure below sends an additional begining and ending quote
Sub TestSendKeys() Dim s As String s = "A dumb thing to do." SendKeys """" & s & """" End Sub
Hello Vmusic,
I don't mean this in a nasty way, but given that the relatively simple
solution to the above has evaded you, I'm not sure if the following
alternative would be viable for you or not... but here it is anyway,
hopefully it will be of some help.
What about simply copying the contents of the variable to the clipboard?
I do this myself for, example, when a user wants to examine the SQL my
apps have generated in other places (for example, an Oracle SQL
statement to be examined in SQL Plus, Enterprise Manager, etc). http://www.mvps.org/access/api/api0049.htm
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Sub TestSendkeys()
Dim retval
Dim strtxt As String
retval = Shell("Notepad.exe", 1)
strtxt = "Using Sendkeys can be dangerous..."
SendKeys strtxt
End Sub
Arno R
"Vmusic" <ak*****@irisicom.net> schreef in bericht news:11*********************@g10g2000cwb.googlegro ups.com... Business requirements aren't necessarily stupid. Thank you Dr. Chao for your consideration, however your function adds an extra quote character. I want to send ONLY the characters from the variable. Your procedure below sends an additional begining and ending quote Sub TestSendKeys() Dim s As String s = "A dumb thing to do." SendKeys """" & s & """" End Sub
On 18 Mar 2006 14:24:39 -0800, "Vmusic" <ak*****@irisicom.net> wrote: Business requirements aren't necessarily stupid.
Thank you Dr. Chao for your consideration, however your function adds an extra quote character. I want to send ONLY the characters from the variable. Your procedure below sends an additional begining and ending quote
Sub TestSendKeys() Dim s As String s = "A dumb thing to do." SendKeys """" & s & """" End Sub
You could use scripting, eg
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "Notepad.exe"
Do Until Success = True
Success = objShell.AppActivate("Notepad")
Wscript.Sleep 1000
Loop
objShell.SendKeys "This is a test."
see http://www.microsoft.com/technet/scr....mspx?mfr=true
for further information on this type of thing including some (but not all) of the drawbacks.
Very handy. Thanks for the post. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jesper |
last post by:
How can I open a textfile from C# using notepad (or the
user assigned application for this).
|
by: Tiësto |
last post by:
Sometimes I have a string variable with many escaped characters. And when I
write
?MyString
in the Immediate window, the output is done with the \n \t and similar
characteres.
Is there any...
|
by: cagey cretin |
last post by:
I have set up a catch/try deal to find an error, but there are none
reported nor when I clean the build/rebuild. Simple filecalled
text_file.txt. I cannot write to it, but I can write into it with...
|
by: Nina |
last post by:
Hi there,
What is the maximum length that one line can hold in a text file using
StreamWriter's Write or WriteLine method? If the string is too long for one
line to hold, what will Write or...
|
by: Tim |
last post by:
Hi,
What I am trying to accomplish is to initiate remote desktop session from
within my C# application to XP Pro machine NOT terminal services to a
server.
I have not found any way to do this...
|
by: Niron kag |
last post by:
Hello !
With c# , I want to write to a text file in a specific font and color.
Any ideas ?
Thanks...
|
by: Ian Boyd |
last post by:
IIS5, on a Windows 2000 Server machine.
Debeg.WriteLine "Hello, world!"
How can i view it?
|
by: aagarwal8 |
last post by:
Hi,
I am trying to write the contents of a textbox to a file in binary
format. My code looks like this...
private void btnWriteToFile_Click(object sender, EventArgs e)
{
FileStream fs =...
|
by: Don |
last post by:
I wrote an app that alerts a user who attempts to open a file that the
file is currently in use. It works fine except when the file is
opened by Notepad. If a text file is opened, most computers...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |