Solved

Sending text to notepad

Posted on 2003-11-18
9
679 Views
Last Modified: 2010-05-01
I want to make a delimited file and send the results to notepad.  Each record needs to be displayed on a new line.  Is there an easy way to do this?
0
Comment
Question by:jennifere
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 1

Expert Comment

by:swdld
ID: 9771472
Hi,
1) write your logs into a local file like 'C:\try.txt'
2) start the file in notepad with
   'shell notepad C:\try.txt'
3) Notepad will start with the file shown which contains your logs

Note: Writing new logs into the file while notepad shows the file will not make any 'updates' within notepad. For having dynamic overview on your logs use a listbox or something like this.

C.U.,
swdld
0
 
LVL 1

Expert Comment

by:jayh99
ID: 9771664
Why don't you store the items you want to send to notepad in variables, then try:

Public strStored As String

Private Sub Command1_Click()
strStored = "Put the information from your delimited file here"
Open "C:\Notepad.txt" For Append As #1
Write #1, strStored
Close #1
End Sub
0
 

Author Comment

by:jennifere
ID: 9771910
I am sending a lot of data to notepad.  This data is stored in a collection and is going to to executed in a for loop, therefore, - I'm assuming here, re-opening and closing the file may be slow.  I tryed using Shell to open Notepad.  Notepad opens okay, but I am unsure how to write my data to it.....
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 26

Expert Comment

by:EDDYKT
ID: 9772011
0
 
LVL 9

Accepted Solution

by:
TooKoolKris earned 125 total points
ID: 9773022
Here is a script (.vbs) you could use. No need to close the file until you're done with it.

Sub OpenTextFileTest
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForAppending, True)
   f.WriteLine "Hello world!"
   f.Close
End Sub
0
 

Author Comment

by:jennifere
ID: 9773379
Thanks TooKoolKris.  That works!   =)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9773468
Is it necesary to use notepad? Why don't you simply append lines to a text box control.
If not, EDDY has an excelent workaround with that link.
TooKoolKris, i don't see how it would be useful, there is no code to "update" notepad there.
0
 
LVL 9

Expert Comment

by:TooKoolKris
ID: 9773547
Well I guess it's not very important to see why it would be useful to you it's jennifere who needs to use it. When she adds this to here loop statement it will append the current .txt file with a new line for each record. Notepad is not needed. The only thing that need to be updated(appended) is the text file.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9773594
Rich,


May be I mis-read the question.

?8->
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 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