Problem with Japanese Characters

keo

New Member
Joined
Oct 23, 2011
Messages
3
First time post here...

I have a question, I'm using the functions Dir() and FileDateTime() to check if a file exists and the date of a certain file

Now this file has Japanese characters in it, I was able to change the settings in Windows so I can see the Japanese characters both in the folder where the files are located and in the VBA editor(I hard coded the file names) now whenever I run the tool VBA doesn't seem to be picking up the file in Dir() it's just blank and on FileDateTime() it says the file doesn't exist
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
thanks for the reply pgc :D

sadly though that didn't resolve the problem, I'm getting an error that the file can't be found

I hardcoded the filename for testing, the filename I pasted in the editor appears as Japanese characters. I save that to a string variable.

however when I pass through this lines of code the value in the variable where the Japanese characters should be becomes garbage. I try doing a messagebox and it shows the garbage values instead of the correct ones but when I try it on the immediate window it comes out correctly
 
Upvote 0
sadly though that didn't resolve the problem, I'm getting an error that the file can't be found

Hi

First of all I must say that I don't know Japanese and so maybe a Japanese member of the board can give you better information.

I just did a small test and it worked ok.

I created the file (hope it means house):

社内.txt in the folder c:\tmp

The name has 2 Japanese characters. I compose it in the code.

I then set the reference to Microsoft Scripting Runtime and ran:

Code:
Sub JapaneseName()
Dim s As String, sPathname As String
Dim fso As FileSystemObject
Dim fsoFile As File
Dim dt As Date
 
s = ChrW(31038) & ChrW(20869) ' house in japanese (hope it's correct)
sPathname = "c:\tmp\" & s & ".txt"
 
Set fso = New FileSystemObject
Set fsoFile = FSO.GetFile(sPathname)
dt = fsoFile.DateLastModified
 
MsgBox "Date of last modification: " & Format(dt, "yyyy-mm-dd hh:mm:ss")
End Sub

It displayed the date correctly


I try doing a messagebox and it shows the garbage values instead of the correct ones but when I try it on the immediate window it comes out correctly

Yes, the default MsgBox does not display the Japanese characters. If you want to display the filename in a message box, create a small userform with a label and use it to display the characters.
 
Last edited:
Upvote 0
thanks pgc!

I saw what you did there by getting the char value of the Ascii code.. but sadly as I also don't speak Japanese I can't get every character of the filename :(
 
Upvote 0
thanks pgc!

I saw what you did there by getting the char value of the Ascii code.. but sadly as I also don't speak Japanese I can't get every character of the filename :(

Why not? Just copy it for ex. to a cell and read it to a string.

Copy and post it here if you have difficulties and I'll give it a try.

Remark: it's not the ascii codes, it's the unicode codes.
 
Upvote 0

Forum statistics

Threads
1,213,528
Messages
6,114,154
Members
448,553
Latest member
slaytonpa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top