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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -