method or data member not found

C

Curt

code from web says it will do what I want Will run on sheet I use xx.xx
hangs on
..CreateTextFile
tswrite.writeline OutPutLine on writeline
have suggested code to test works fine

Dim FSO As Scripting.FileSystemObject
Dim AAA As Scripting.TextStream
Set FSO = New Scripting.FileSystemObject
Set AAA = FSO.CreateTextFile("C:\Parade\ZZZ.txt")

do't know what I've got wrong in this is it another setting in references?
Following is download from web
'The code below will write a CSV file and will not output anything for a
blank line
Sub WriteCSV()
Dim fwrite As Variable
Dim fswrite As Variable
Dim WritePathName As Variable
Dim writeline As Variable
Dim CreateTextFile As Variable
Const MyPath = "C:\Parade\"
Const WriteFileName = "text.csv"
Const Delimiter = ","
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Set fswrite = CreateObject("Scripting.FileSystemObject")
'open files
WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)

lastrow = Cells(Rows.Count, "A").End(xlUp).row

For RowCount = 1 To lastrow
lastcol = Cells(RowCount, Columns.Count).End(xlToLeft).Column
For ColCount = 1 To lastcol
If ColCount = 1 Then
OutPutLine = Cells(RowCount, ColCount)
Else
OutPutLine = OutPutLine & Delimiter & Cells(RowCount, ColCount)
End If
Next ColCount
OutPutLine = Trim(OutPutLine)
If Len(OutPutLine) <> 0 Then
tswrite.writeline OutPutLine
End If
Next RowCount

tswrite.Close

End Sub

' 65,536 rows in the csv file. Is there something I can do, within Excel,
' preferably programatically, to ensure that only rows with data are
presented for import.

If this can be whipped I sure will be a happy person
Thanks for help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top