How to Rename a File from English to Other Language?

rafeemd

New member
Joined
Feb 2, 2012
Messages
3
Reaction score
0
Points
0
I really hope someone can help me with this because I need to do,
I have an excel file with some columns and one column having file name in English and other column having the filename in other language. Now i need to do is rename the file in other language, is it possible to rename.

I tried this code
Code:
Sub pdfrenamefile()
Dim oldfile As String
Dim nwfile As String
Dim rng As Range
Dim fname As Range
Set rng = Range("Y7", Range("Y" & Rows.Count).End(xlUp))
For Each fname In rng
If IsEmpty(fname) Or fname = "" Then
Else
If FileFolderExists(Cells(1, 1)&fname) Then
nwfile = fname.Offset(, 1)&".PDF"
Name Cells(1, 1)&fname As Cells(1, 1) & nwfile
fname.Offset(0, 2)=nwfile
fname.Offset(0, 3)="Success"
Else
Range("AB"&fname.Row)="File Not Found"
End If
End If
Next fname
End Sub

Example :
Sample Data ID OldFileName NewFileName
1 Sales1.PDF తెలుగు1.PDF
2 Sales02.PDF తెలుగు02.PDF
3 Sales567.PDF తెలుగు567.PDF
4 dest67.PDF తెలుగు67.PDF
I tried but it converting only into english, but not accepting to other.
Thanks in advance for any help.
 
Last edited by a moderator:
I think VBA struggles with Arabic, it is not Unicode.
 
Thank You Phillips for your response.
How to overcome this, for other languages, like Chinese French, Telugu,Hindi ...
I dont know how to do.
please help me to solve this problem
Thanks
 
rafeemd,

In the case of the Arabic example you posted above, when I paste that into the visual basic editor, it comes back with Sales567.PDF ??????567.PDF. The challenge is that VBA is written in English.

I'll admit that I don't do a lot of multilingual work, but I'm not aware of any VBA functionality to generate the file names in non-english character sets.

I will shoot off an email to a friend though, and see if he can add anything.
 
I believe that it can be done...

Hi rafeemd, I've never used Arabic version but currently I'm a Japanese version user so I hope I can help you out somehow.

Handling other language on a pure English environment, I think all the character should be treated in Unicode. Unicode isn't supported on a Visual Basic for the Macintosh Environment, but it's available on Windows. So I think you can use it as long as you are using Windows OS.

But as Ken posted in above, all the Arabic is displayed as ??? in VBE, same thing happens on my Japanese environment because our machine doesn't have Arabic character as default. So we have to change those to a simple character code using ASC function so that we can treat it with CHR function.

For example, if you'd like to save this workbook as あ.xls (It's a file name with Japanese character), you can do it as follows.

ThisWorkbook.SaveAs Chr(-32096) & ".xls"

But to do that, you need to check the character code in advance using ASC.

I guess it cannot be done simply in VBE. Because on VBE, all the Arabic character would be shown as ???. As of now, I have an idea however I've tried it yet because I had no time today (sorry). What I have on my mind is that saving those Arabic file names as an html file then read it from VBA using ASC function. As this posting shows, in html format, all of us can see Arabic character. So I'm sure that it can be done if we try like my idea...

Anyway, I'll be back here later. ;-)
 
Done

Or if you can have those Arabic file name on a worksheet, it can be used.
Here on my Japanese vers, it can be done. What I tested is as follows.

Put a file name on a cell A1

c:\తెలుగు02.xls

Then tried this and it worked.

Code:
Thisworkbook.SaveAs Sheets(1).range("A1").value

Hope this helps.


Ken, any time, mate!
 
Interesting Colo. I had a problem with Arabic last year. I was able to use the Arabic text it by just using worksheet values, but I have a feeling that trying to save the file just wouldn't work. Maybe it was because they had a combination of English settings and Arabic language packs? WE certainly ended up saving them with English names.
 
Nice meeting you here again, I'm glad that you look fine, Bob.


Because of Japanese font set is based on a 2-byte character as well as Arabic, that's why I could save the file with Arabic letters. English alphabed is a 1-byte character right? But it sounds strange however we've not installed Arabic language pack, we can see those Arabic letters posted on this thread.
 
Colo, that was way too easy... I was expecting some massive HTML conversion, or a huge engine to compare each character against a library of Chr codes! Well done!
 
Yeah, some massive HTML conversion is my line. In other words, most of difficult things can be done with Excel alone like this time. Well done, Excel!
 
Back
Top