C
Curt
First go at creating and writing to text file. Having read copy paste not way
to go. Found code that will create text file in help. Also searched and found
code that will write all data and not write blank rows or cells. Having a
problem bringing the code together. Also have had method or data member not
found show up on .CreateTextFile & .writeline Output. Once I get this
combined can move on.
Will enclose the code I have in place.
Thanks to All
Sub AAAA()
Dim lastrow As Variable
Dim RowCount As Integer
Dim lastcol As Variable
Dim ColCount As Integer
Dim OutPutLine As Variable
Dim Delimiter As Variable
Dim tswrite As Variable
Dim writeline As String
Dim FSO As Scripting.FileSystemObject
Dim AAA As Scripting.TextStream
Set FSO = New Scripting.FileSystemObject
Set AAA = FSO.CreateTextFile("C:\Parade\ZZZ.txt")
AAA.writeline "This Is Line One"----This part works fine as is
'Worksheets("mailE").Activate
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 ---this is writeline hang up.
CreateTextFile is in another module had to set reference to get first part to
operate may need to set more thanks again---
End If
Next RowCount
End Sub
to go. Found code that will create text file in help. Also searched and found
code that will write all data and not write blank rows or cells. Having a
problem bringing the code together. Also have had method or data member not
found show up on .CreateTextFile & .writeline Output. Once I get this
combined can move on.
Will enclose the code I have in place.
Thanks to All
Sub AAAA()
Dim lastrow As Variable
Dim RowCount As Integer
Dim lastcol As Variable
Dim ColCount As Integer
Dim OutPutLine As Variable
Dim Delimiter As Variable
Dim tswrite As Variable
Dim writeline As String
Dim FSO As Scripting.FileSystemObject
Dim AAA As Scripting.TextStream
Set FSO = New Scripting.FileSystemObject
Set AAA = FSO.CreateTextFile("C:\Parade\ZZZ.txt")
AAA.writeline "This Is Line One"----This part works fine as is
'Worksheets("mailE").Activate
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 ---this is writeline hang up.
CreateTextFile is in another module had to set reference to get first part to
operate may need to set more thanks again---
End If
Next RowCount
End Sub