473,770 Members | 6,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Write a variable to Notepad

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

Mar 18 '06 #1
11 16229
Vmusic wrote:
Ahhhh.... Why is something so simple SO HARD


Because it's incredibly stupid?

Mar 18 '06 #2
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

Mar 18 '06 #3
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.

Mar 18 '06 #4
"JuChao" <jc******@hotma il.com> wrote in
news:11******** *************@z 34g2000cwc.goog legroups.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.
Mar 18 '06 #5
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_F ile()
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:\WINDO WS\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


Mar 18 '06 #6
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

Mar 18 '06 #7
"Vmusic" <ak*****@irisic om.net> wrote in
news:11******** *************@g 10g2000cwb.goog legroups.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.
Mar 18 '06 #8
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
Mar 19 '06 #9
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*****@irisic om.net> schreef in bericht news:11******** *************@g 10g2000cwb.goog legroups.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

Mar 19 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
107958
by: Jesper | last post by:
How can I open a textfile from C# using notepad (or the user assigned application for this).
2
3136
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 simple way to write the string as normal text? Thank you.
2
2233
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 notepad and read it with StreamReader. Can anyone show me the error of my ways? //AppendText() Method #using <mscorlib.dll> using namespace System;
12
11132
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 WriteLine do? In order me to retrieve data correctly from the text file later, I have to know the right index. For the following code,if str1's length exceeds one line in text file, how can I get str2's index when reading the text file? Is there...
1
10583
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 with code (if you know of a way then I would love to hear about it). What I have created so far is; 1. Write RDP file to the HD from the code
14
17029
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...
46
24272
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
6
5245
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 = File.Open(@"D:\test.dat", FileMode.OpenOrCreate, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs);
36
5401
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 are configured to use Notepad to open the file by default and if they are configured to use Notepad by default I want it to remain that way rather than retrieve the text into my app or force the user to use another app to read the file. I'm...
0
9595
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.