method or data member not found

  • Thread starter Thread starter Curt
  • Start date Start date
C

Curt

took code out of help in excel so I must have a setting missing? Need some
direction as to what is missing.
Thank You

Sub CreateAfile()
Set fs = CreateObject("Scripting.FileSystemObject")
Set A = fs.CreateTextFile("c:\testfile.txt", True)-----.CreateTextFile
not found
A.writeline ("This is a test.")
A.Close
End Sub
 
Your code works fine for me. Try setting a reference to the Scripting
Runtime and declare the variables explicitly. In VBA, go to the Tools menu,
choose References, and select "Microsoft Scripting RunTime". Then use code
like

Sub AAAA()
Dim FSO As Scripting.FileSystemObject
Dim AAA As Scripting.TextStream

Set FSO = New Scripting.FileSystemObject
Set AAA = FSO.CreateTextFile("C:\ZZZ.txt")
AAA.writeline "This Is Line One"
End Sub


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
FYI cannot get in thru your link in e-mail blank screen was good earlier
today. Got in thru another e-mail
thanks
 
That did the trick for that problem. I got code that says it will do what I
want to not write any empty rows. Not knowledgeable enough to integreat into
your code. This is my first attemp at a text file. Will send what I've got
and carry on
Thanks so much

Sub AAAA()
Dim lastrow As Variable
Dim RowCount As Variable
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"

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

End Sub
 
Back
Top