Como enviar listados a un fichero de texto

Jes?
29 de Septiembre del 2003
Hola. Tengo un programa en Visual Basic con el que saco listados directamente a la impresora. Con Printer.Print
¿ Como puedo enviar estos listados a un fichero de texto y no a la impresora ?

Un saludo a todos

sdemingo
29 de Septiembre del 2003
Hola, te mando unos ejemplillos de cómo tratar ficheros de texto desde VB para leer, escribir y añadir.
Necesitas el FileSystemObject para hacerlo así.

Sub Create_File()
Dim fso, txtfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile("c:testfile.txt", True)
txtfile.Write ("This is a test. ") ' Write a line.
' Write a line with a newline character.
txtfile.WriteLine ("Testing 1, 2, 3.")
' Write three newline characters to the file.
txtfile.WriteBlankLines (3)
txtfile.Close
End Sub

Sub Read_Files()

Dim fso As New FileSystemObject, txtfile, _
fil1 As File, ts As TextStream
fso.CreateTextFile "c:testfile.txt", True
MsgBox "Writing file"
' Write a line.
Set fil1 = fso.GetFile("d:prueba.txt")
Set ts = fil1.OpenAsTextStream(ForWriting)
ts.Write "Hello World"
ts.Close
' Read the contents of the file.
Set ts = fil1.OpenAsTextStream(ForReading)
s = ts.ReadLine
MsgBox s
ts.Close
End Sub

Sub Manip_Files()
Dim fso As New FileSystemObject, txtfile, fil1, fil2
Set txtfile = fso.CreateTextFile("c:testfile.txt", True)
MsgBox "Writing file"
' Write a line.
txtfile.Write ("This is a test.")
' Close the file to writing.
txtfile.Close
MsgBox "Moving file to c:tmp"
' Get a handle to the file in root of C:.
Set fil1 = fso.GetFile("c:testfile.txt")
' Move the file to tmp directory.
fil1.Move ("c:tmptestfile.txt")
MsgBox "Copying file to c:temp"
' Copy the file to temp.
fil1.Copy ("c:temptestfile.txt")
MsgBox "Deleting files"
' Get handles to files' current location.
Set fil1 = fso.GetFile("c:tmptestfile.txt")
Set fil2 = fso.GetFile("c:temptestfile.txt")
' Delete the files.
fil1.Delete
fil2.Delete
MsgBox "All done!"
End Sub


Private Sub Command1_Click()
Read_Files
End Sub

Un saludo
sdemingo