excel - Write to text file in VBA -
i trying print file after opening file create vba. part stuck @ writing file. here have far.
sub test() dim myfile string dim testfile string dim intchoice integer dim fs, f myfile = application.getsaveasfilename & "kml" open myfile output #1 application.filedialog(msofiledialogopen).allowmultiselect = false intchoice = application.filedialog(msofiledialogopen).show if intchoice <> 0 testfile = application.filedialog( _ msofiledialogopen).selecteditems(1) end if set fs = createobject("scripting.filesystemobject") set f = fs.opentextfile(testfile) print #1, f close #1 end sub
read textstream line-by-line , print needed. in loop.
set fs = createobject("scripting.filesystemobject") set f = fs.opentextfile(testfile) while not f.atendofstream print #1, f.readline loop set f = nothing set fs = nothing
or, may able omit loop , print #1, f.readall
.
Comments
Post a Comment