Problem reading Chinese characters in Excel file using Visual Basic

I open the excel file, which contains Chinese characters, to read its contents, with:

Set appexcel = Excel.Application
Set appexcel = CreateObject("excel.application")

appexcel.Workbooks.Open "file.xls"

temp = appexcel.Cells(1,1)

appexcel.Workbooks.Close

appexcel.Quit
Set appexcel = Nothing

PROBLEM: When the excell cell contains Chinese characters, temp reads them as just question marks, .

QUESTION: How can the above be fixed, so that VB can retain the Chinese characters



Answer this question

Problem reading Chinese characters in Excel file using Visual Basic

  • Isty Ahmad

    This class will not exist for vb6.     The code/suggestions given will reflect this.

    These forums are for VB.NET and there are better places to find answers for older versions of VB such as vb6 

    Maybe the VB6 newgroups - http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.vb.general.discussion&lang=en&cr=US

    or possibly  www.vbcity.com

     

     

     


  • oaix

    This may be a text encoding issue , I recall issues like this in the past.

    Instead of

    dim temp as string

    you may want to try

    dim temp as system.text.UTFxEncoding - where x is one of the possible values, intellisense will help you out a little here with possible types

    or

    dim temp as system.text.UniCodeEncoding

    And see if that helps.


  • ArtySaravana

    I tried system.text.UTF8Encoding with no luck. I don't think it works with VB6, which is what I use.

    Any other ideas


  • Problem reading Chinese characters in Excel file using Visual Basic