Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Im trying to append the info in an array which has numbers and letters. I cannot get the array to write to it. This does work because Ive tried the appending "hello World" to it. It also appends the "," Any help is appreciated Thanks And Thanks again for the many helps this group has provided to me Mike Dim myarray(19) as Variant Dim fs, f, ts, s, chk Set fs = CreateObject("Scripting.FileSystemObject") chk = fs.FileExists("c:\data.txt") If chk = True Then ' check if file exists Set f = fs.GetFile("c:\data.txt") Set ts = f.OpenAsTextStream(8, 0) ts.write "Hello World" For i = 1 To 19 ts.write myarray(i) & "," Next ts.write vbCrLf ts.Close Else 'if not create file fs.CreateTextFile "c:\data.txt" 'creates file Set f = fs.GetFile("c:\data.txt") Set ts = f.OpenAsTextStream(8, 0) ts.write "Hello World" For i = 1 To 19 ts.write myarray(i) & "," Next ts.write vbCrLf ts.Close End If |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Susan,
Any good reason why you are using the FSO in VBA ? If not, then check out VBA's "Open" statement. It will be more simple because: "If the file specified by pathname doesn't exist, it is created when a file is opened for Append, Binary, Output, or Random modes." NickHK "Susan Hayes" wrote in message ... Hi Im trying to append the info in an array which has numbers and letters. I cannot get the array to write to it. This does work because Ive tried the appending "hello World" to it. It also appends the "," Any help is appreciated Thanks And Thanks again for the many helps this group has provided to me Mike Dim myarray(19) as Variant Dim fs, f, ts, s, chk Set fs = CreateObject("Scripting.FileSystemObject") chk = fs.FileExists("c:\data.txt") If chk = True Then ' check if file exists Set f = fs.GetFile("c:\data.txt") Set ts = f.OpenAsTextStream(8, 0) ts.write "Hello World" For i = 1 To 19 ts.write myarray(i) & "," Next ts.write vbCrLf ts.Close Else 'if not create file fs.CreateTextFile "c:\data.txt" 'creates file Set f = fs.GetFile("c:\data.txt") Set ts = f.OpenAsTextStream(8, 0) ts.write "Hello World" For i = 1 To 19 ts.write myarray(i) & "," Next ts.write vbCrLf ts.Close End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Append text file | Excel Discussion (Misc queries) | |||
Append data from a column to separate table array | Excel Programming | |||
append file on e-mail | Excel Programming | |||
append file on e-mail | Excel Discussion (Misc queries) | |||
File Append Row by Cell value | Excel Programming |