S
spradl
Hi,
I am trying to create a dynamic CSV file via
FileSystemObject.CreateTextFile. I have no problem creating the CSV
file normally but I would like to insert comments and VBScript into
the coding.
Normally, the file would look something like this:
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\somefile.txt", True)
filetxt.WriteLine "This is the first CSV value," &_
"This is the second," &_
"And this is the third"
However, I would like something more like this:
filetxt.WriteLine "one," &_ 'This is the first CSV value
Do While Not objRs.EOF
objRs("itemNumber") & "," &_ 'These are the rest of the values
objRs.MoveNext: Loop
I have tried creating a string first and then inputting the data like:
text = "one," &_ 'This is the first CSV value
Do While Not objRs.EOF
text = text & objRs("itemName") & "," &_ 'These are the rest of the
values
objRs.MoveNext: Loop
filetxt.WriteLine text
However, this gave the error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'fs.writeline'
Any suggestions on how to solve this problem???
I am trying to create a dynamic CSV file via
FileSystemObject.CreateTextFile. I have no problem creating the CSV
file normally but I would like to insert comments and VBScript into
the coding.
Normally, the file would look something like this:
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\somefile.txt", True)
filetxt.WriteLine "This is the first CSV value," &_
"This is the second," &_
"And this is the third"
However, I would like something more like this:
filetxt.WriteLine "one," &_ 'This is the first CSV value
Do While Not objRs.EOF
objRs("itemNumber") & "," &_ 'These are the rest of the values
objRs.MoveNext: Loop
I have tried creating a string first and then inputting the data like:
text = "one," &_ 'This is the first CSV value
Do While Not objRs.EOF
text = text & objRs("itemName") & "," &_ 'These are the rest of the
values
objRs.MoveNext: Loop
filetxt.WriteLine text
However, this gave the error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'fs.writeline'
Any suggestions on how to solve this problem???