View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Roger Govier[_3_] Roger Govier[_3_] is offline
external usenet poster
 
Posts: 2,480
Default DIR fn when filename has non-ANSI characters

Hi Simon

Why do you want to do it with DIR?
Could you not use the File Scripting Object to do it directly through VBA?

Here is some code posted by Jim Cone which should do what you want.

Sub ListAllFilesInFolder()
'Jim Cone - Portland Oregon - USA
Dim strPath As String
Dim oFSO As Object
Dim oFile As Object
Dim oFolder As Object
Dim N As Long

strPath = "C:\Program Files\Microsoft Office\Office11"

N = 1
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(strPath)
Cells(N, 1).Value = oFolder.Path
N = N + 1
For Each oFile In oFolder.Files
Cells(N, 2).Value = oFile.Name
N = N + 1
Next 'oFile
Set oFSO = Nothing
Set oFile = Nothing
Set oFolder = Nothing
End Sub



--
Regards
Roger Govier

"simonc" wrote in message
...
A DOS listing in a comand window returns the question mark character as
well.
I will have to find some other way to get these file names into a
spreadsheet. I can do it manually, one file at a time, in Explorer if I
use
file rename and copy the filename text without actually changing it, but
there are a lot of files...

"Joel" wrote:

I'm guessing, but I think it really has to do with the operating system
and
not Excel. there are regional settings in the registry that determines
the
language and Excel rreturns the same values that DOS would return. To
help
determine if it is an excel problem or a windows Problem try the
following.

Open a DOS window by going to start button - Press Run - In text box
enter
exe.cmd and press OK. the enter DIR and your filename. You can change
drives by typing H: and changing folder by typing cd TEMP (you can also
use
wildcards like * and ? with cd)

"simonc" wrote:

I want to use the DIR function to extract the names of files in a
directory
and write them into a spreadsheet. As the filenames are all in Russian
they
are all non-ANSI characters and DIR simply returns a question mark
character
for each letter in the file name. Is there a way of getting DIR to read
non-ANSI?

Grateful for advice.