excel - Getting "" in the file instead of " which is not expected -
there code in button click workbooks saved local text files.
workbook contains below info:
critical; insert ifparam values(3498,'tat_unalloctradesrec','string','if(string(c5)=string("tce - external hedge"),string("e"),if(string(c5)=string("tce - internal hedge"),string("i"),string(c5)))');
but output comes critical;
insert ifparam values(3498,'tat_unalloctradesrec','string','if(string(c5)=string(""tce - external hedge""),string(""e""),if(string(c5)=string(""tce - internal hedge""),string(""i""),string(c5)))'); issue ever there " getting "" in output. can me in getting in workbook i.e; single double quote " instead of ""
please suggest if code change needed. code used :
private sub commandbutton1_click() dim xlbook workbook, xlsheet worksheet dim stroutputfilename string dim n long, long, j long dim mydata string, strdata() string, myarray() string dim strpath string strpath = activeworkbook.path '<~~ \\plyalnppd3sm\d$\temp\arun\tat\ thisworkbook.savecopyas strpath & "\temp.xls" set xlbook = workbooks.open(strpath & "\temp.xls") each xlsheet in xlbook.worksheets if xlsheet.name <> "user_provided_data" stroutputfilename = strpath & "\" & xlsheet.name & ".zup" xlsheet.saveas filename:=stroutputfilename, fileformat:=xltextmsdos n = n + 1 redim preserve myarray(n) myarray(n) = stroutputfilename debug.print stroutputfilename end if next xlbook.close savechanges:=false kill strpath & "\temp.xls" = 1 ubound(myarray) '~~> open files in 1 go , store them in array open myarray(i) binary #1 mydata = space$(lof(1)) #1, , mydata close #1 strdata() = split(mydata, vbcrlf) '~~> write text file open myarray(i) output #1 '~~> loop through array , check if start , end has " '~~> , if ignore , write text file j = lbound(strdata) ubound(strdata) if left(strdata(j), 1) = """" , right(strdata(j), 1) = """" strdata(j) = mid(strdata(j), 2, len(strdata(j)) - 2) end if print #1, strdata(j) next j close #1 next end sub
easiest solution without looking @ code - add in line before outputting strdata(j) text file:
strdata(j) = replace(strdata(j), """""", """") i'm sure there nicer ways, simple, quick , dirty fix!
Comments
Post a Comment