excel - Convert to text using VB-macro (including line breaks within cells) -
i convert excel sheet several text files. sheet contains 2 columns:
- column gives names generated text files
- column b provides content - contains line breaks within cells
the conversion works using following code, line breaks not imported text file - text in 1 line:
private sub commandbutton1_click() dim otxt object each cell in ark1.range("a1:a" & ark1.usedrange.rows.count) ' can change sheet1 own choice savetext = cell.text open "h:\webshop_zpider\s-solutions" & savetext & ".txt" output #1 print #1, cell.offset(0, 1).text close #1 next cell end sub
can me that?
hi, result of using siddharths suggestions: line breaks included! generated files not named , saved wanted. files name s-solutions plus content of colum (e.g. s-solutionss-4001-k-t.txt) , saved in folder h:\webshop_zpider. however, want is: filename: content of colum (e.g.s-4001-k-t.txt) , folder h:\webshop_zpider\s-solutions. how can change that? thanks.
replace this
print #1, cell.offset(0, 1).text
with
print #1, replace(cell.offset(0, 1).value, vblf, vbcrlf)
also 1 tip! not use .text
. use .value
Comments
Post a Comment