Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: How to Rename a File from English to Other Language?

  1. #1

    How to Rename a File from English to Other Language?



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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 Bob Phillips; 2012-02-02 at 02:01 PM. Reason: Added code tags

  2. #2
    I think VBA struggles with Arabic, it is not Unicode.

  3. #3
    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

  4. #4
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,209
    Articles
    57
    Blog Entries
    14
    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.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  5. #5
    Neophyte Colo's Avatar
    Join Date
    Feb 2012
    Location
    Kobe Japan
    Posts
    4
    Articles
    0

    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. ;-)

  6. #6
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,209
    Articles
    57
    Blog Entries
    14
    Welcome Colo! Thanks for stopping in to lend a hand here.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  7. #7
    Neophyte Colo's Avatar
    Join Date
    Feb 2012
    Location
    Kobe Japan
    Posts
    4
    Articles
    0

    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!

  8. #8
    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.

  9. #9
    Neophyte Colo's Avatar
    Join Date
    Feb 2012
    Location
    Kobe Japan
    Posts
    4
    Articles
    0
    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.

  10. #10
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,209
    Articles
    57
    Blog Entries
    14
    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!
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training) or with my book M is for Data Monkey!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Page 1 of 2 1 2 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •