Error 52: Bad File Name (Chinese characters)

I'm using access 2003 vba...

I hope this comes through clearly:  I have the following file name that 
includes chinese characters (there are thousands of these files that need 
renaming, the example below has the first 2 characters as chinese symbols, 
but they could be embedded anywhere in the file name):

Example:
答复_China brochure.msg

I'm doing a rename process using VBA (ie, name oldname as newname).

I'm getting the error:  Error 52:  Bad file name or number...

Obviously, VBA can't find the original file name as it doesn't recognize it 
(the chinese characters come across as "??")

Any ideas?  Thanks.
-- 
Craig
0
Utf
3/25/2010 11:12:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

21 Replies
4466 Views

Similar Articles

[PageSpeed] 13

On Thu, 25 Mar 2010 16:12:01 -0700, Craig
<Craig@discussions.microsoft.com> wrote:

Check out the information at the bottom of this page:
http://accessblog.net/2007_06_01_archive.html

-Tom.
Microsoft Access MVP


>I'm using access 2003 vba...
>
>I hope this comes through clearly:  I have the following file name that 
>includes chinese characters (there are thousands of these files that need 
>renaming, the example below has the first 2 characters as chinese symbols, 
>but they could be embedded anywhere in the file name):
>
>Example:
>??_China brochure.msg
>
>I'm doing a rename process using VBA (ie, name oldname as newname).
>
>I'm getting the error:  Error 52:  Bad file name or number...
>
>Obviously, VBA can't find the original file name as it doesn't recognize it 
>(the chinese characters come across as "??")
>
>Any ideas?  Thanks.
0
Tom
3/26/2010 3:28:53 AM
???

I'm confused...you mean the section "How to write out Unicode text files in 
VBA"???
-- 
Craig


"Tom van Stiphout" wrote:

> On Thu, 25 Mar 2010 16:12:01 -0700, Craig
> <Craig@discussions.microsoft.com> wrote:
> 
> Check out the information at the bottom of this page:
> http://accessblog.net/2007_06_01_archive.html
> 
> -Tom.
> Microsoft Access MVP
> 
> 
> >I'm using access 2003 vba...
> >
> >I hope this comes through clearly:  I have the following file name that 
> >includes chinese characters (there are thousands of these files that need 
> >renaming, the example below has the first 2 characters as chinese symbols, 
> >but they could be embedded anywhere in the file name):
> >
> >Example:
> >??_China brochure.msg
> >
> >I'm doing a rename process using VBA (ie, name oldname as newname).
> >
> >I'm getting the error:  Error 52:  Bad file name or number...
> >
> >Obviously, VBA can't find the original file name as it doesn't recognize it 
> >(the chinese characters come across as "??")
> >
> >Any ideas?  Thanks.
> .
> 
0
Utf
3/26/2010 4:51:01 AM
Hi Craig,

What OS are you using?  Can you open the file(s) by double clicking?

How are you getting the current filename into oldfilename for your 'name 
oldfilename as newfilename' command?

Cheers,
Alex.


"Craig" wrote:

> I'm using access 2003 vba...
> 
> I hope this comes through clearly:  I have the following file name that 
> includes chinese characters (there are thousands of these files that need 
> renaming, the example below has the first 2 characters as chinese symbols, 
> but they could be embedded anywhere in the file name):
> 
> Example:
> 答复_China brochure.msg
> 
> I'm doing a rename process using VBA (ie, name oldname as newname).
> 
> I'm getting the error:  Error 52:  Bad file name or number...
> 
> Obviously, VBA can't find the original file name as it doesn't recognize it 
> (the chinese characters come across as "??")
> 
> Any ideas?  Thanks.
> -- 
> Craig
0
Utf
3/26/2010 7:00:01 AM
Hello...thanks for the response.

i'm using XP....

Here's the thing...you can't see the chinese characters in Windows explorer 
because it can't display them.  The characters are there, they just show up 
as litte squares (think carriage returns, etc.).

What I want to do is replace these characters with some other character 
(like an underscore or something).  So in my vba script I read open the file 
as such:

dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
with application.filesearch
...blah blah
oldname= .foundfiles(x)

Then, I cursor through each character in this name to find non ascii 
characters and replace them with an underscore.

Then, this:

Name oldname as newname

This is where I get the error.  The problem is when I read the filename into 
vba it doesn't recognize the chinese characters.  So it doesn't recognize 
"oldname".

I hope this makes sense.

I'm thinking I need to get load a library of chinese characters or something..

Thanks for any and all help.  Signing off for the evening but will check in 
the AM
-- 
Craig


"Tokyo Alex" wrote:

> Hi Craig,
> 
> What OS are you using?  Can you open the file(s) by double clicking?
> 
> How are you getting the current filename into oldfilename for your 'name 
> oldfilename as newfilename' command?
> 
> Cheers,
> Alex.
> 
> 
> "Craig" wrote:
> 
> > I'm using access 2003 vba...
> > 
> > I hope this comes through clearly:  I have the following file name that 
> > includes chinese characters (there are thousands of these files that need 
> > renaming, the example below has the first 2 characters as chinese symbols, 
> > but they could be embedded anywhere in the file name):
> > 
> > Example:
> > 答复_China brochure.msg
> > 
> > I'm doing a rename process using VBA (ie, name oldname as newname).
> > 
> > I'm getting the error:  Error 52:  Bad file name or number...
> > 
> > Obviously, VBA can't find the original file name as it doesn't recognize it 
> > (the chinese characters come across as "??")
> > 
> > Any ideas?  Thanks.
> > -- 
> > Craig
0
Utf
3/26/2010 7:36:01 AM
Response inline:

"Craig" <Craig@discussions.microsoft.com> wrote in message 
news:BF8272EB-07A2-41BD-B9B6-A6D5FF9B65F7@microsoft.com...
> Hello...thanks for the response.
>
> i'm using XP....
>
> Here's the thing...you can't see the chinese characters in Windows 
> explorer
> because it can't display them.  The characters are there, they just show 
> up
> as litte squares (think carriage returns, etc.).
>
> What I want to do is replace these characters with some other character
> (like an underscore or something).  So in my vba script I read open the 
> file
> as such:
>
> dim fs
> Set fs = CreateObject("Scripting.FileSystemObject")
> with application.filesearch
> ..blah blah
> oldname= .foundfiles(x)
>
> Then, I cursor through each character in this name to find non ascii
> characters and replace them with an underscore.

One thing you could try. Read the whole file into a string variable, delete 
the file, then write the string out as a newly named file:

Dim f As Integer, buf As String

f = FreeFile
Open FileName For Binary Access Read As f
buf = Space(LOF(f))
Get #f, , buf
Close f

Kill Filename

'Modify the filename here

Open NewName For Binary Access Write As f
Put #f, , buf
Close f

Of course that will only work so long as the VBA Open statement can deal 
with the spurious chars. I don't know if the fso can also do this, because I 
don't use it much. (I don't have time to test anything today).

HTH

>
> Then, this:
>
> Name oldname as newname
>
> This is where I get the error.  The problem is when I read the filename 
> into
> vba it doesn't recognize the chinese characters.  So it doesn't recognize
> "oldname".
>
> I hope this makes sense.
>
> I'm thinking I need to get load a library of chinese characters or 
> something..
>
> Thanks for any and all help.  Signing off for the evening but will check 
> in
> the AM
> -- 
> Craig
>
>
> "Tokyo Alex" wrote:
>
>> Hi Craig,
>>
>> What OS are you using?  Can you open the file(s) by double clicking?
>>
>> How are you getting the current filename into oldfilename for your 'name
>> oldfilename as newfilename' command?
>>
>> Cheers,
>> Alex.
>>
>>
>> "Craig" wrote:
>>
>> > I'm using access 2003 vba...
>> >
>> > I hope this comes through clearly:  I have the following file name that
>> > includes chinese characters (there are thousands of these files that 
>> > need
>> > renaming, the example below has the first 2 characters as chinese 
>> > symbols,
>> > but they could be embedded anywhere in the file name):
>> >
>> > Example:
>> > ??_China brochure.msg
>> >
>> > I'm doing a rename process using VBA (ie, name oldname as newname).
>> >
>> > I'm getting the error:  Error 52:  Bad file name or number...
>> >
>> > Obviously, VBA can't find the original file name as it doesn't 
>> > recognize it
>> > (the chinese characters come across as "??")
>> >
>> > Any ideas?  Thanks.
>> > -- 
>> > Craig 


0
Stuart
3/26/2010 12:05:14 PM
On Thu, 25 Mar 2010 21:51:01 -0700, Craig
<Craig@discussions.microsoft.com> wrote:

I was hoping you could write:
Name StrConv(strFile, vbUnicode) As "renamed.txt"
but indeed that does not work. I will have to look into this some
more.

-Tom.
Microsoft Access MVP


>???
>
>I'm confused...you mean the section "How to write out Unicode text files in 
>VBA"???
0
Tom
3/26/2010 2:26:47 PM
Thanks for the response.

No, VBA can't read the spurious characters.  It shows them as "?"  But, I 
can replace any "?" with an underscore.  That's what I do to create "newname".

And I guess that's the overall problem:  VBA reads the characters as "?".  
Then, when it encounters this statement:

Name oldname as newname

....it tries to find and replace the file in explorer (with the chinese 
characters) with "oldname", but obviously can't as "oldname" has "?" instead 
of chinese characters.

Geez, now my head's spinning  ;o)

I'll give this a shot and report back.

Thanks.
-- 
Craig


"Stuart McCall" wrote:

> Response inline:
> 
> "Craig" <Craig@discussions.microsoft.com> wrote in message 
> news:BF8272EB-07A2-41BD-B9B6-A6D5FF9B65F7@microsoft.com...
> > Hello...thanks for the response.
> >
> > i'm using XP....
> >
> > Here's the thing...you can't see the chinese characters in Windows 
> > explorer
> > because it can't display them.  The characters are there, they just show 
> > up
> > as litte squares (think carriage returns, etc.).
> >
> > What I want to do is replace these characters with some other character
> > (like an underscore or something).  So in my vba script I read open the 
> > file
> > as such:
> >
> > dim fs
> > Set fs = CreateObject("Scripting.FileSystemObject")
> > with application.filesearch
> > ..blah blah
> > oldname= .foundfiles(x)
> >
> > Then, I cursor through each character in this name to find non ascii
> > characters and replace them with an underscore.
> 
> One thing you could try. Read the whole file into a string variable, delete 
> the file, then write the string out as a newly named file:
> 
> Dim f As Integer, buf As String
> 
> f = FreeFile
> Open FileName For Binary Access Read As f
> buf = Space(LOF(f))
> Get #f, , buf
> Close f
> 
> Kill Filename
> 
> 'Modify the filename here
> 
> Open NewName For Binary Access Write As f
> Put #f, , buf
> Close f
> 
> Of course that will only work so long as the VBA Open statement can deal 
> with the spurious chars. I don't know if the fso can also do this, because I 
> don't use it much. (I don't have time to test anything today).
> 
> HTH
> 
> >
> > Then, this:
> >
> > Name oldname as newname
> >
> > This is where I get the error.  The problem is when I read the filename 
> > into
> > vba it doesn't recognize the chinese characters.  So it doesn't recognize
> > "oldname".
> >
> > I hope this makes sense.
> >
> > I'm thinking I need to get load a library of chinese characters or 
> > something..
> >
> > Thanks for any and all help.  Signing off for the evening but will check 
> > in
> > the AM
> > -- 
> > Craig
> >
> >
> > "Tokyo Alex" wrote:
> >
> >> Hi Craig,
> >>
> >> What OS are you using?  Can you open the file(s) by double clicking?
> >>
> >> How are you getting the current filename into oldfilename for your 'name
> >> oldfilename as newfilename' command?
> >>
> >> Cheers,
> >> Alex.
> >>
> >>
> >> "Craig" wrote:
> >>
> >> > I'm using access 2003 vba...
> >> >
> >> > I hope this comes through clearly:  I have the following file name that
> >> > includes chinese characters (there are thousands of these files that 
> >> > need
> >> > renaming, the example below has the first 2 characters as chinese 
> >> > symbols,
> >> > but they could be embedded anywhere in the file name):
> >> >
> >> > Example:
> >> > ??_China brochure.msg
> >> >
> >> > I'm doing a rename process using VBA (ie, name oldname as newname).
> >> >
> >> > I'm getting the error:  Error 52:  Bad file name or number...
> >> >
> >> > Obviously, VBA can't find the original file name as it doesn't 
> >> > recognize it
> >> > (the chinese characters come across as "??")
> >> >
> >> > Any ideas?  Thanks.
> >> > -- 
> >> > Craig 
> 
> 
> .
> 
0
Utf
3/26/2010 4:26:15 PM
Actually, I think I answered my own question.  This won't work as VB can't 
read the spurious characters...

I think I'm going to need to load a library of chinese characters so my 
system can see them...if that's at all possible.

Unless anyone can think of something else?

Thanks.
-- 
Craig


"Craig" wrote:

> Thanks for the response.
> 
> No, VBA can't read the spurious characters.  It shows them as "?"  But, I 
> can replace any "?" with an underscore.  That's what I do to create "newname".
> 
> And I guess that's the overall problem:  VBA reads the characters as "?".  
> Then, when it encounters this statement:
> 
> Name oldname as newname
> 
> ...it tries to find and replace the file in explorer (with the chinese 
> characters) with "oldname", but obviously can't as "oldname" has "?" instead 
> of chinese characters.
> 
> Geez, now my head's spinning  ;o)
> 
> I'll give this a shot and report back.
> 
> Thanks.
> -- 
> Craig
> 
> 
> "Stuart McCall" wrote:
> 
> > Response inline:
> > 
> > "Craig" <Craig@discussions.microsoft.com> wrote in message 
> > news:BF8272EB-07A2-41BD-B9B6-A6D5FF9B65F7@microsoft.com...
> > > Hello...thanks for the response.
> > >
> > > i'm using XP....
> > >
> > > Here's the thing...you can't see the chinese characters in Windows 
> > > explorer
> > > because it can't display them.  The characters are there, they just show 
> > > up
> > > as litte squares (think carriage returns, etc.).
> > >
> > > What I want to do is replace these characters with some other character
> > > (like an underscore or something).  So in my vba script I read open the 
> > > file
> > > as such:
> > >
> > > dim fs
> > > Set fs = CreateObject("Scripting.FileSystemObject")
> > > with application.filesearch
> > > ..blah blah
> > > oldname= .foundfiles(x)
> > >
> > > Then, I cursor through each character in this name to find non ascii
> > > characters and replace them with an underscore.
> > 
> > One thing you could try. Read the whole file into a string variable, delete 
> > the file, then write the string out as a newly named file:
> > 
> > Dim f As Integer, buf As String
> > 
> > f = FreeFile
> > Open FileName For Binary Access Read As f
> > buf = Space(LOF(f))
> > Get #f, , buf
> > Close f
> > 
> > Kill Filename
> > 
> > 'Modify the filename here
> > 
> > Open NewName For Binary Access Write As f
> > Put #f, , buf
> > Close f
> > 
> > Of course that will only work so long as the VBA Open statement can deal 
> > with the spurious chars. I don't know if the fso can also do this, because I 
> > don't use it much. (I don't have time to test anything today).
> > 
> > HTH
> > 
> > >
> > > Then, this:
> > >
> > > Name oldname as newname
> > >
> > > This is where I get the error.  The problem is when I read the filename 
> > > into
> > > vba it doesn't recognize the chinese characters.  So it doesn't recognize
> > > "oldname".
> > >
> > > I hope this makes sense.
> > >
> > > I'm thinking I need to get load a library of chinese characters or 
> > > something..
> > >
> > > Thanks for any and all help.  Signing off for the evening but will check 
> > > in
> > > the AM
> > > -- 
> > > Craig
> > >
> > >
> > > "Tokyo Alex" wrote:
> > >
> > >> Hi Craig,
> > >>
> > >> What OS are you using?  Can you open the file(s) by double clicking?
> > >>
> > >> How are you getting the current filename into oldfilename for your 'name
> > >> oldfilename as newfilename' command?
> > >>
> > >> Cheers,
> > >> Alex.
> > >>
> > >>
> > >> "Craig" wrote:
> > >>
> > >> > I'm using access 2003 vba...
> > >> >
> > >> > I hope this comes through clearly:  I have the following file name that
> > >> > includes chinese characters (there are thousands of these files that 
> > >> > need
> > >> > renaming, the example below has the first 2 characters as chinese 
> > >> > symbols,
> > >> > but they could be embedded anywhere in the file name):
> > >> >
> > >> > Example:
> > >> > ??_China brochure.msg
> > >> >
> > >> > I'm doing a rename process using VBA (ie, name oldname as newname).
> > >> >
> > >> > I'm getting the error:  Error 52:  Bad file name or number...
> > >> >
> > >> > Obviously, VBA can't find the original file name as it doesn't 
> > >> > recognize it
> > >> > (the chinese characters come across as "??")
> > >> >
> > >> > Any ideas?  Thanks.
> > >> > -- 
> > >> > Craig 
> > 
> > 
> > .
> > 
0
Utf
3/26/2010 5:31:02 PM
Tom van Stiphout <tom7744.no.spam@cox.net> wrote in
news:5faoq59c45n3ec10dtavbabu0lg4kgiva5@4ax.com: 

> Check out the information at the bottom of this page:
> http://accessblog.net/2007_06_01_archive.html

Sorry, but I'm not seeing how that relates to file names.

-- 
David W. Fenton                  http://www.dfenton.com/ 
usenet at dfenton dot com    http://www.dfenton.com/DFA/
0
David
3/26/2010 5:46:56 PM
=?Utf-8?B?Q3JhaWc=?= <Craig@discussions.microsoft.com> wrote in
news:90DE1146-0DCF-4908-8062-B3332CC53465@microsoft.com: 

> I'll give this a shot and report back.

Have you tried using the File System Object instead of VBA file I/O
functions? 

-- 
David W. Fenton                  http://www.dfenton.com/ 
usenet at dfenton dot com    http://www.dfenton.com/DFA/
0
David
3/26/2010 5:48:56 PM
Yes...on my previous thread I posted this:

dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
with application.filesearch
...blah blah
oldname= .foundfiles(x)

Assuming the file has 2 chinese characters in the beginning of the name, VB 
reads the file as "??filename.msg".

Unless I misinterpreted the question?
-- 
Craig


"David W. Fenton" wrote:

> =?Utf-8?B?Q3JhaWc=?= <Craig@discussions.microsoft.com> wrote in
> news:90DE1146-0DCF-4908-8062-B3332CC53465@microsoft.com: 
> 
> > I'll give this a shot and report back.
> 
> Have you tried using the File System Object instead of VBA file I/O
> functions? 
> 
> -- 
> David W. Fenton                  http://www.dfenton.com/ 
> usenet at dfenton dot com    http://www.dfenton.com/DFA/
> .
> 
0
Utf
3/26/2010 8:13:02 PM
"Craig" <Craig@discussions.microsoft.com> wrote in message 
news:0149CDCC-A260-443E-B434-5DE309F3FD7C@microsoft.com...
> Yes...on my previous thread I posted this:
>
> dim fs
> Set fs = CreateObject("Scripting.FileSystemObject")
> with application.filesearch
> ..blah blah
> oldname= .foundfiles(x)
>
> Assuming the file has 2 chinese characters in the beginning of the name, 
> VB
> reads the file as "??filename.msg".
>
> Unless I misinterpreted the question?
> -- 
> Craig
<snip>

You could give this a shot: grab the file's short path and feed that to Name 
or Open & see if vba can then deal with it:

http://www.smccall.demon.co.uk/Strings.htm#ShortPath


0
Stuart
3/26/2010 11:07:59 PM
Hi Craig,

I had the chance to do some testing, and I couldn't find much to help.

I deal with (Japanese) DBCS file and object names all the time, and although 
Access is usually pretty good, this really threw it a curve.

I can display (in Windows Explorer) your file name, and can open and act on 
the file.  Access can store and display it properly in a table, and VBA can 
read it, and write it to that table correctly.

But, debug.print filename can't display the non-Japanese DBCS characters, 
they come out as "?", as in your case.  And, of course, name OFN as NFN fails 
with error 52.

It seems that it fails when there's no native way of displaying the filename 
in Windows, in which case Windows reverts to Unicode which it can display but 
not process.

I'm thinking you have 2 possible solutions:
If you're using XP Pro, I believe you can download language packs from MS 
(I'm not sure if they're free).  So you could get the Chinese language pack 
and IME which should allow native display and processing of Chinese filenames.

Or, there may be some way other than the filename to refer to the file and 
force VBA to open it.  This may be beyond VBA, and is certainly beyond my 
knowledge of VBA.

Not very helpful, I know, but that's all I can think of right now.  I'll 
post back if anything else occurs to me.

Cheers,
Alex.


"Stuart McCall" wrote:

> "Craig" <Craig@discussions.microsoft.com> wrote in message 
> news:0149CDCC-A260-443E-B434-5DE309F3FD7C@microsoft.com...
> > Yes...on my previous thread I posted this:
> >
> > dim fs
> > Set fs = CreateObject("Scripting.FileSystemObject")
> > with application.filesearch
> > ..blah blah
> > oldname= .foundfiles(x)
> >
> > Assuming the file has 2 chinese characters in the beginning of the name, 
> > VB
> > reads the file as "??filename.msg".
> >
> > Unless I misinterpreted the question?
> > -- 
> > Craig
> <snip>
> 
> You could give this a shot: grab the file's short path and feed that to Name 
> or Open & see if vba can then deal with it:
> 
> http://www.smccall.demon.co.uk/Strings.htm#ShortPath
> 
> 
> .
> 
0
Utf
3/27/2010 1:19:01 AM
On Fri, 26 Mar 2010 07:26:47 -0700, Tom van Stiphout
<tom7744.no.spam@cox.net> wrote:

OK, I think I figured it out.
You can't use the Dir function to iterate over the filenames.
Apparently Dir returns an ascii string, not a unicode string.
The FileSystemObject works much better:
    Dim fs As Scripting.FileSystemObject
    Dim fil As Scripting.File
    Dim fol As Scripting.Folder
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set fol = fs.GetFolder("c:\test\")
    For Each fil In fol.Files
        If AscW(fil.name) > 255 Then Stop
    Next fil
    Set fol = Nothing
    Set fs = Nothing

I created a file in the test folder and gave it a leading Chinese
character (u+5609 in my case). I ran the above code and it stops at
that file. When I hover over fil.name I see a questionmark for that
character. I conclude that the debug tooltip cannot display unicode
chars. When I debug.print fil.name I also get a questionmark. I
conclude the debug window (at least on a US version of Windows and
Office) cannot display unicode chars.
But AscW can handle unicode chars, and the above code proves that
fil.name is a unicode string.
So now you can write:
fil.name = "renamed.txt" and you will have renamed the unicode file.

-Tom.
Microsoft Access MVP




>On Thu, 25 Mar 2010 21:51:01 -0700, Craig
><Craig@discussions.microsoft.com> wrote:
>
>I was hoping you could write:
>Name StrConv(strFile, vbUnicode) As "renamed.txt"
>but indeed that does not work. I will have to look into this some
>more.
>
>-Tom.
>Microsoft Access MVP
>
>
>>???
>>
>>I'm confused...you mean the section "How to write out Unicode text files in 
>>VBA"???
0
Tom
3/27/2010 3:15:47 AM
Thank you very much.

Yes, I get the same errors ("?" showing up in place of the character).

At this point I might tap into my  forensic/ediscovery comrades to see if 
there are alternative software solutions (ie LAW, Encase, etc.).  I will 
report back here with findings.

VB has yet to fail me, though.  I would be interested to discover a VB 
workaround if possible.

Thanks.
-- 
Craig


"Tokyo Alex" wrote:

> Hi Craig,
> 
> I had the chance to do some testing, and I couldn't find much to help.
> 
> I deal with (Japanese) DBCS file and object names all the time, and although 
> Access is usually pretty good, this really threw it a curve.
> 
> I can display (in Windows Explorer) your file name, and can open and act on 
> the file.  Access can store and display it properly in a table, and VBA can 
> read it, and write it to that table correctly.
> 
> But, debug.print filename can't display the non-Japanese DBCS characters, 
> they come out as "?", as in your case.  And, of course, name OFN as NFN fails 
> with error 52.
> 
> It seems that it fails when there's no native way of displaying the filename 
> in Windows, in which case Windows reverts to Unicode which it can display but 
> not process.
> 
> I'm thinking you have 2 possible solutions:
> If you're using XP Pro, I believe you can download language packs from MS 
> (I'm not sure if they're free).  So you could get the Chinese language pack 
> and IME which should allow native display and processing of Chinese filenames.
> 
> Or, there may be some way other than the filename to refer to the file and 
> force VBA to open it.  This may be beyond VBA, and is certainly beyond my 
> knowledge of VBA.
> 
> Not very helpful, I know, but that's all I can think of right now.  I'll 
> post back if anything else occurs to me.
> 
> Cheers,
> Alex.
> 
> 
> "Stuart McCall" wrote:
> 
> > "Craig" <Craig@discussions.microsoft.com> wrote in message 
> > news:0149CDCC-A260-443E-B434-5DE309F3FD7C@microsoft.com...
> > > Yes...on my previous thread I posted this:
> > >
> > > dim fs
> > > Set fs = CreateObject("Scripting.FileSystemObject")
> > > with application.filesearch
> > > ..blah blah
> > > oldname= .foundfiles(x)
> > >
> > > Assuming the file has 2 chinese characters in the beginning of the name, 
> > > VB
> > > reads the file as "??filename.msg".
> > >
> > > Unless I misinterpreted the question?
> > > -- 
> > > Craig
> > <snip>
> > 
> > You could give this a shot: grab the file's short path and feed that to Name 
> > or Open & see if vba can then deal with it:
> > 
> > http://www.smccall.demon.co.uk/Strings.htm#ShortPath
> > 
> > 
> > .
> > 
0
Utf
3/27/2010 3:40:01 AM
Thank you Tom...don't know how I missed that...

-- 
Craig


"Tom van Stiphout" wrote:

> On Fri, 26 Mar 2010 20:40:01 -0700, Craig
> <Craig@discussions.microsoft.com> wrote:
> 
> Check my answer in another part of this thread.
> -Tom.
> 
> 
> >Thank you very much.
> >
> >Yes, I get the same errors ("?" showing up in place of the character).
> >
> >At this point I might tap into my  forensic/ediscovery comrades to see if 
> >there are alternative software solutions (ie LAW, Encase, etc.).  I will 
> >report back here with findings.
> >
> >VB has yet to fail me, though.  I would be interested to discover a VB 
> >workaround if possible.
> >
> >Thanks.
> .
> 
0
Utf
3/27/2010 7:01:02 AM
=?Utf-8?B?Q3JhaWc=?= <Craig@discussions.microsoft.com> wrote in
news:0149CDCC-A260-443E-B434-5DE309F3FD7C@microsoft.com: 

> Yes...on my previous thread I posted this:
> 
> dim fs
> Set fs = CreateObject("Scripting.FileSystemObject")
> with application.filesearch
> ..blah blah
> oldname= .foundfiles(x)
> 
> Assuming the file has 2 chinese characters in the beginning of the
> name, VB reads the file as "??filename.msg".

But what command are you using to rename the file? VBA's Name
command or the FSO MoveFile method? 

Also, have you tried operating directly on the name returned by the
FoundFiles collection instead of assigning it to a string variable? 

-- 
David W. Fenton                  http://www.dfenton.com/ 
usenet at dfenton dot com    http://www.dfenton.com/DFA/
0
David
3/28/2010 11:00:38 PM
=?Utf-8?B?Q3JhaWc=?= <Craig@discussions.microsoft.com> wrote in
news:0149CDCC-A260-443E-B434-5DE309F3FD7C@microsoft.com: 

> Yes...on my previous thread I posted this:
> 
> dim fs
> Set fs = CreateObject("Scripting.FileSystemObject")
> with application.filesearch
> ..blah blah
> oldname= .foundfiles(x)
> 
> Assuming the file has 2 chinese characters in the beginning of the
> name, VB reads the file as "??filename.msg".
> 
> Unless I misinterpreted the question?

Tom van Stiphout has obviously taken this in the direction I was
recomending. In my previous post today, I mis-characterized what you
need to do (I don't use the FSO myself -- I'm partial to simply
using VBA's built-in functions, so I've never quite learned the FSO
object model) -- there is a Name method that works like the VBA Name
command. 

-- 
David W. Fenton                  http://www.dfenton.com/ 
usenet at dfenton dot com    http://www.dfenton.com/DFA/
0
David
3/28/2010 11:04:22 PM
This has been resolved via Tom's suggestion (thanks again).

I had to jerry-rig the code a bit, though, as Tom's code (utilizing the AscW 
function) worked when there was a chinese character at the beginning of the 
file name.  However, I discovered that there were some file names where these 
characters showed up somewhere in the middle of the name...

Thanks for all the input.

-- 
Craig


"Craig" wrote:

> I'm using access 2003 vba...
> 
> I hope this comes through clearly:  I have the following file name that 
> includes chinese characters (there are thousands of these files that need 
> renaming, the example below has the first 2 characters as chinese symbols, 
> but they could be embedded anywhere in the file name):
> 
> Example:
> 答复_China brochure.msg
> 
> I'm doing a rename process using VBA (ie, name oldname as newname).
> 
> I'm getting the error:  Error 52:  Bad file name or number...
> 
> Obviously, VBA can't find the original file name as it doesn't recognize it 
> (the chinese characters come across as "??")
> 
> Any ideas?  Thanks.
> -- 
> Craig
0
Utf
3/30/2010 10:53:01 PM
On Mar 30, 5:53=C2=A0pm, Craig <Cr...@discussions.microsoft.com> wrote:
> This has been resolved via Tom's suggestion (thanks again).
>
> I had to jerry-rig the code a bit, though, as Tom's code (utilizing the A=
scW
> function) worked when there was a chinese character at the beginning of t=
he
> file name. =C2=A0However, I discovered that there were some file names wh=
ere these
> characters showed up somewhere in the middle of the name...
>
> Thanks for all the input.
>
> --
> Craig
>
>
>
> "Craig" wrote:
> > I'm using access 2003 vba...
>
> > I hope this comes through clearly: =C2=A0I have the following file name=
 that
> > includes chinese characters (there are thousands of these files that ne=
ed
> > renaming, the example below has the first 2 characters as chinese symbo=
ls,
> > but they could be embedded anywhere in the file name):
>
> > Example:
> > =E7=AD=94=E5=A4=8D_China brochure.msg
>
> > I'm doing a rename process using VBA (ie, name oldname as newname).
>
> > I'm getting the error: =C2=A0Error 52: =C2=A0Bad file name or number...
>
> > Obviously, VBA can't find the original file name as it doesn't recogniz=
e it
> > (the chinese characters come across as "??")
>
> > Any ideas? =C2=A0Thanks.
> > --
> > Craig- Hide quoted text -
>
> - Show quoted text -

Hey Craig,
I've done it old school.  I created text file and named it with your
file name above.  In Windows XP Pro, it displayed the boxes as you're
seeing.  In DOS it displays the "??".

Simple batch file was able to handle it two different ways.

  @echo off
  copy "??_China brochure.msg" NewName.msg
  del "??_China brochure.msg"

  ren "??_China brochure2.msg" NewName2.msg

If you can read in the file names with your function write out a batch
file with all the rename commands and then shell to it.  It's almost
too easy.... hehehe

Hope this helps,
Chris M.
0
mcescher
3/31/2010 1:43:15 PM
Good to know...thanks for that.

-- 
Craig


"mcescher" wrote:

> On Mar 30, 5:53 pm, Craig <Cr...@discussions.microsoft.com> wrote:
> > This has been resolved via Tom's suggestion (thanks again).
> >
> > I had to jerry-rig the code a bit, though, as Tom's code (utilizing the AscW
> > function) worked when there was a chinese character at the beginning of the
> > file name.  However, I discovered that there were some file names where these
> > characters showed up somewhere in the middle of the name...
> >
> > Thanks for all the input.
> >
> > --
> > Craig
> >
> >
> >
> > "Craig" wrote:
> > > I'm using access 2003 vba...
> >
> > > I hope this comes through clearly:  I have the following file name that
> > > includes chinese characters (there are thousands of these files that need
> > > renaming, the example below has the first 2 characters as chinese symbols,
> > > but they could be embedded anywhere in the file name):
> >
> > > Example:
> > > 答复_China brochure.msg
> >
> > > I'm doing a rename process using VBA (ie, name oldname as newname).
> >
> > > I'm getting the error:  Error 52:  Bad file name or number...
> >
> > > Obviously, VBA can't find the original file name as it doesn't recognize it
> > > (the chinese characters come across as "??")
> >
> > > Any ideas?  Thanks.
> > > --
> > > Craig- Hide quoted text -
> >
> > - Show quoted text -
> 
> Hey Craig,
> I've done it old school.  I created text file and named it with your
> file name above.  In Windows XP Pro, it displayed the boxes as you're
> seeing.  In DOS it displays the "??".
> 
> Simple batch file was able to handle it two different ways.
> 
>   @echo off
>   copy "??_China brochure.msg" NewName.msg
>   del "??_China brochure.msg"
> 
>   ren "??_China brochure2.msg" NewName2.msg
> 
> If you can read in the file names with your function write out a batch
> file with all the rename commands and then shell to it.  It's almost
> too easy.... hehehe
> 
> Hope this helps,
> Chris M.
> .
> 
0
Utf
3/31/2010 4:16:01 PM
Reply:

Similar Artilces:

Excel Progrom Error
Hi there Happy new year to all. I often receive the folowing error message in a box titled "Program Error". EXCEL.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created. The only option is OK which closes Excel. I do not know where the error log is created. I am using Office 2000 Service Pack 3 with Windows 2000 Professsional Service Pack 4. Can anybody throw some light on this error. Thanks in anticipation. Michael What are you doing at the time (i.e. is it consistent)? -- Regards; Rob ----------------...

Sharebuilder account import error
Invalid .qif header error when trying to import .qif file from sharebuilder accounts. Anyone know of a fix or experienced this problem?? I typed a long mail to sharebuilder regarding this issue...still waiting fora reply. Hopefully they will be able to help. Microsoft flat out told me it wasn't their issue and to contact my broker! No help AT ALL. Microshaft..... OMalley ...

I need to widen my screen so I can print a wide file?
How do I do this? I need to print a copy that shows all the script which is too wide. I'm not sure what you are trying to do, but changing to Landscape orientation might help. Assuming that you are using Word 2007, click the Page Layout tab, and then click Orientation in the Page Setup group. -- Stefan Blom Microsoft Word MVP "bingo" <bingo@discussions.microsoft.com> wrote in message news:CA925BD1-D8EF-408B-9588-4F5BF7FCD554@microsoft.com... > How do I do this? > I need to print a copy that shows all the script which is too wide. ...

DPM2010 RC Errors on secondary server.
We have recently upraded our 2007 SP1 Primary DPM server to 2010 RC and it is working perfectly. I've set up a brand new, fresh Windows 2008 R2 Server for the secondary server, and have told it to protect one of the protection groups on the primary server. Everything works for a little while, but every half hour or so, the DPM service crashes and says: "Connection to the DPM service has been lost. Review the application event log for information about a possible service shutdown. ID: 917" Then asks to restart the administrator console. This kills the ...

ERROR
Hi I am using a spreadsheet in Excel 2002 on Windows XP, for some reason the account numbers (which someone input, along with addresses) have a little green mark in the corner of the cell. I thought it was to show that there is a comment, but it is not. When you click on the cell, a little warning sign shows, saying ERROR - number in this cell formatted as text or preceded by an apostrophe. When I click on the arrow by the warning sign, it says Number stored as text Convert to number Ignore error Edit in formula bar Error checking options Show formula in audinting toolbar Now I looked a...

Change organisation name in Exchange 2003
Hi, We are migrating our XCH 5.5 to XCH 2003. We need to change the organisation name. We can not use XMERGE as we need to keep the rights on the folders. So we need the new 2003 to join the 5.5 organisation: we can not create a new organisation and migrate the mailboxes. Is there a way, once the migration is over, to change the organisation name in Exchange 2003 ? Thks, Alex On Sun, 9 Jan 2005 00:11:35 +0100, "Alex" <alex@alex.alex> wrote: >Hi, > >We are migrating our XCH 5.5 to XCH 2003. We need to change the organisation >name. We can not use XMERGE as we n...

error, chkdsk
Questio, when I try to open excel or winmx, an error pops up saying chkdsk, so i ran a chkdsk and it doesnt do anything. The error also says corrupted file. In excel I have some important work that I need to open, and it only opens in Turkish, if I change it to English, its a bunch of boxes and letters, its not my work I need. How do I change it back. What excel version are you using? Try to find somebody with 2003 to see if they can open the file. Otherwise you would look for some commercial software that might be of help http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B30...

4.4.7 error
I have problems on one client that they don't recieve all emails from people sending to them. I guess something is wrong in the configuration. When I do a nslookup -type=mx domain.com I just get unautharized answer. Also the ttl time is just 1800 when I do a dns report. Do the guys that handle the dns change this? The people that doesn't get their mail throw get the 4.4.7 error in return. Best regards Jimmy http://support.microsoft.com/kb/555375 -- Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." .. "Surfer&q...

error 0x800CCC0F
Dear Team; I am receiving the following error messages, please assist Could result be sent to lewis.king@riotinto.com regards Lew Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Subject 'brocolli & mushroom stir fry noodle', Account: 'pop.gmail.com', Server: 'smtp.gmail.com', Protocol: SMTP, Port: 995, Secure(SSL): Yes, Error Number: 0x800CCC0F Your server has unexpectedly terminated the connection. Possible causes for this include server p...

delete server...routing master error
hello, I have 2 exchange servers (exch 2003) and i have to delete one of them. I changed all replication etc...(before we had also a 5.5 which is already removed) but when i stop the services and try to remove the server via system manager of my second exchange (the one that will stay) i get an error message that my server that i want to delete is the routing master for that group. How can i make my other server the routing master ? i don't have any site replication (deleted it because not necessary anymore). thnx, Philippe Go to routing groups > first routing group > mem...

Excel error codes translations
hi, Does anybody know where I can find a kind of dictionary for Exce errors? The problem is sometimes I get an error message that is not in Englis and without error code and then looking for the solution I must kno its equivalent in English. Regards, Micha -- Message posted from http://www.ExcelForum.com ...

toolbar, date, services, errors, paste, minimized system restore doesn't work
I have a XP system that the toolbar does not show open programs, services do not seem to load at boot, the date is off by one month, I cannot paste anything that I copy, and system restore does not work. All of these issues started at the same time a few days ago. Has anyone else seen this group of errors? I am trying to resolve and do not know if it is a system update gone bad, or if maybe it is a viruse/malware issue. Please let me know if you had had these problems together and what you did to fix them. There is a very good chance that you are seeing the effects of a hi...

Re: Money 2004
Thanks for the suggestion. I tried unregistering/re-registering the msxml3 DLL, but still no luck. However, knowing the help file topics are local might help with debugging this problem. thanks, randy "Randy" <nospam@hotmail.com> wrote in message news:... > All, > > I've recently upgraded to Money 2004 Premium from 2003 Deluxe. I'm now > finding that I can't view any help topics--I get the "Unable to load topic. > Click here to try again." I've tried all the suggestions posted here and at > other sites: cleared out temporary in...

Default File Renaming
When I save my files as webpages Publisher automatically renames alllllll of my files to Img001 Img002 etc etc and I have to go through the HTML and change ALL the file names so that it pulls the right pictures... my site is huge, this is tedious and annoying... can anyone help??? It is not renaming your image files, it is making copies of them. If you are renaming those copies than your page won't load the images because the file names will be wrong. I recommend you visit my site and review the articles I have for the version you are using. If you require anything further please use ...

Clicked a .prf. file and woosh
Help! I accidentally clicked on a file with a .prf extension (some utility that keeps it preferences stored in such a file). To my surprise this not only started Outlook but also triggered some Outlook installation dialog. When I clicked that away I ended up with a completely new and empty Outlook! At first I was flabberghasted, since ALL my mails, my calendar entries, contacts, etc. EVERYTHING seemed gone! When I just doublechecked I saw, that this thing apparently created a new Outlook1.pst file which seems to be used as the new default. It seems that my old file "Outlook.pst&q...

how to install .oft files (forms) on a Clustered Exchange?
Hi All I have Exchange 2000 cluster active/passive. How does I install Outlook forms (.oft) files on a Clustered Exchange? Thank you, Jack Black ...

"File Error: Data May Be Lost" error when opening workbook saved in Mac
When I open in Excel 2007 for Windows workbook with charts saved in Mac OS, I see the message "File Error: Data May Be Lost". In Excel 2003 for Windows this message appears as many times as many sheets there are in workbook. Maybe someone knows what's the reason? Unfortunately you haven't provided the info needed... "Mac OS" means very little. The question is "What version of Mac Excel are you using, what file format are the files saved as & what type of content is in the files?" In general, what you're running into is that Excel 2003 &a...

Printing out multiple files from a form
I have a table, tDistrictSub, in Access 2003 that contains various pieces of information. The relevant fields in this table for this problem are: DistrictIncidentNum - the pk (always a 9-digit number, then a dash, followed by another 9 digit number) DistrictIncidentID - the 9-digit number in front of the dash from above I also have a table, tAttachments, that has the following fields: AttachmentID - the pk (autogenerated) DistrictIncidentNum - linked to tDistrictSub Attachment - contains the filename of an attachment. I've created a form, fDistrictSub, that lists information for any...

Technical error
AMEX and Discover are not being sent over to the credit card processor during settlement. I comes up with a "TECHNICAL ERROR". Visa and MC are settling fine. Does anyone know what the problem is?? All are setup as different tranaction types in RMS and ALL authorize fine during the transaction process. Your merchant account is not correctly configured for AMEX & Discover. This is on the bank's side, not RMS. -- Glenn Adams Tiber Creek Consulting http://www.tibercreek.com glenn@tibercreek.com ---------------------------------------------- Please DO NOT respond to me dir...

Can't move items to PST file
Ever see a message when moving an email (with attachment) from your In Box to a subfolder in a Personal Folder (pst) that Outlook "Can't move the items. The item could not be moved. It was already moved or deleted, or access was denied." Thanks for any help you can provide! Greg PS. We don't have any mailbox limits set on the network. What is the overall size of the .PST file and how many items are in the folder you're trying to move the item to? Also, what version of Outlook are you using? -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address ...

CObject Private method access error
Hi, I am trying to recompile application that has been developed in VC++ 6.0 with VC++2005.. While compiling, I'm getting the following error.. error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(553) : see declaration of 'CObject::CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(524) : see declaration of 'CObject' 1> This diagnostic occurred in the compiler generated function 'CExcepti...

Error in closing Outlook
Application error ciceroUIWndFrame. The instruction at 0x7e430240 reference memory cannot be written 0x7e42631A Also unable to dial a phone using Outlook. Sanford Take a look here http://support.microsoft.com/kb/323613 -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "Sanford Aranoff" <aranoff@analysis-knowledge.com> wrote in message news:4B6CD165.E7510293@analysis-knowledge.com... > Application error ciceroUIWndFrame. > The instruction at 0x7e430240 reference me...

Typing message error
I have an Asus Eee PC netbook which came with a Microsoft Works 2007 trial. I'm unable to type anything on a Word document. An error message flashes briefly at the bottom of the screen, "This modification is not allowed because the selection is locked." I'm baffled. Is this a computer problem or a Works problem and how can this be fixed? Thank you. I would be surprised if any system nowadays came with a Works trial; more likely it is an Office 2007 trial (and if it *is* Works, then you're in the wrong discussion group). If the computer is quite new, then...

Can't Erase Tapes: DPM Fails with Error ID:3308
I attempt to erase a tape and every time the DPM console crashes (sometimes two hours into the tape erase) and there is this error: * (000002L4) could not be erased for the following reason: (ID 3308) * DPM service terminated unexpectedly during completion of the job. The termination may have been caused by a system reboot. (ID 910) I can verify that the server has not rebooted. I'm using DPM 2007, with June Rollup, on Windows Server (x64) 2008. The server is a Dell PowerEdge R710. The tape drive is an LTO4 in a Dell PowerVault 124T Autoloader. This error seems to ...

Text to Columns in excel for delimited files
When using Text to Columns feature in excel for delimited files - allow a trimming feature on the columns as an option. this is a peer-to-peer newsgroup for the asking & (hopefully) answering of excel questions ... if you want to let MS know something you're better off emailling them at mswish@microsoft.com with Excel in the subject line and a detailed explaination of what it is you would like them to implement & why. -- Cheers JulieD check out www.hcts.net.au/tipsandtricks.htm ....well i'm working on it anyway "D. Young" <D. Young@discussions.microsoft.com...