View Full Version : writing text files with vb

06-25-2009, 01:12 PM
hi everybody

I learned how to create a text file and how to write in it using vb. however all the methods i've seen write my text on different lines.

What i have exactly is an excel sheet and on command i need to copy the data from the excel sheet to a text file.

the sheet on the form is S1.

the code i'm using is

Dim newFIle
Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objfile = objFSO.CreateTextFile("C:\poudyn.txt")

objfile.Write S1.Cells(1, 1)
objfile.Write S1.Cells(3, 4)

what i need is to write the content of these 2 cells on the same line

eg : if S1.Cells(1, 1) = 1
and S1.Cells(3, 4) = 6

i want to write in the text file on a line 1 6

if anyone has any idea about how to do that i'd be very very very gratefull.

thanks in advance