anand m

anand m

  • 1.4k
  • 346
  • 35.6k

how to convert ASCII to Unicode when export to excel

Feb 28 2022 11:27 AM

Hello All,

 

I am getting error when i am  record set contains Unicode characters(Chinese)  to export unicode to .xls.

Below is the code ia m using :

Function OutputOneFile(flCnt,  RS, fs)

   Dim strFileName, recCnt, OutFile

   recCnt = 0
   strFileName = Application("OutputPath") & Session("LoginID") & "-" & flCnt & ".xls "

   Set OutFile = fs.CreateTextFile(strFileName,True)

   For i = 0 To RS.Fields.Count - 1
      RowData = RowData & RS(i).Name & vbTab
   Next

   OutFile.WriteLine(RowData)

   Do While ((Not RS.EOF) And (recCnt < 65000))
      RowData=""

      For i = 0 To RS.Fields.Count - 1
         RowData = RowData & RS(i) & vbTab
         RowData = replace(RowData,vbCRLF," ")
      Next

      OutFile.WriteLine(RowData)

      RS.MoveNext
      recCnt = recCnt + 1
   Loop

   OutFile.Close
   Set OutFile = Nothing

   UniqueFileId= "" & DatePart("y",now()) & DatePart("n",now()) & DatePart("s",now()) & ""

 

End Function

 

I am getting error when in between reocrds set contains  Unicode charcters this error message ia m getting below :

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument

 


Answers (2)