excel vba - How to save .txt as Unicode or UTF-8 in VBA -
i want files saved in unicode or utf-8 format , not ansi.
here code:
sub cvelle() dim irow long dim ifile integer dim spath string dim sfile string irow = 1 cells(rows.count, "b").end(xlup).row ifile = freefile rows(irow) spath = "e:\" & .range("b1").value & "\" if len(dir(spath, vbdirectory)) = 0 mkdir spath sfile = .range("d1").value & ".txt" open spath & sfile output #ifile print #ifile, .range("e1").value close #ifile end next irow end sub now, thought inserting code below enough.
sfile = .range("d1").value & ".txt",fileformat:= _xlunicodetext but gives me error.
any suggestion highly appreciated. thanks.
instead of typing bunch of code, figured out make default encoding unicode here how:
1. right click -> new -> text document 2. open "new text document.txt". not type anything! 3. go "file -> save as... " , choose unicode under "encoding:", press "save" , overwrite existing file. close file. 4. rename "new text document.txt" "unicode.txt" 5. copy "unicode.txt" "c:\windows\shellnew" 6. open regedit , navigate hkey_classes_root\.txt\shellnew 7. right click in right window -> new -> "string value" , rename "filename". 8. double click on "filename" , put "unicode.txt" "value data". 9. press ok it's finished. thanks all!
Comments
Post a Comment