View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Workaround for ChDir/CurDir when path has unicode characters

Hi guys, long time.

Problem:
VBA.Filesystem works with ansi paths, not with unicode paths.
e.g. CurDir/ChDir and several other methods return converted strings,
without the actual unicode characters.

For testing:
(English WindowsXP and Excel 97 thru 2007 (or actually VBA 6.5.1020))


Create a folder with a unicode character in the name: Arab?Test
where the ? is unicode x06E9, which looks nice in CharMap,
but any extended unicode character will do.

In that folder create a file with another "foreign" char.

Excel has no problems changing folders and opening/saving files.
However VBA is thoroughly confused.
When I've navigated to the "culprit" folder via excel's File/Open
dialog and i try following in VBE immediate:

ChDir CurDir

I get error 76 path not found!


I've done some research and experimenting:
created following workarounds:

With New Scripting.FileSystemObject
'Retrieve the full unicode string for CurDir.
szCurDir = .GetAbsolutePathName(Vba.CurDir$)
'Change to this folder using short 8.3 name.
vba.ChDir .GetShortPath(vba.CurDir$)
End With

I need a trick for ChDir without short (8.3) paths
(looks terrible AND can be turned of in NTFS)...

I dont mind a ton of apis but it must be foolproof.

--
keepITcool