View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default DIR fn when filename has non-ANSI characters

I think you need to change your registry. There was a problem a couple of
weeks ago the somebody in Israel was defaulting to Turkish language. Not
sure which registry seting is wrong but found an Internet explorer setting in
the website below

http://msdn.microsoft.com/en-us/library/ms902920.aspx

"simonc" wrote:

Roger

This looks more promising. Unfortunately some of these files are in folders
which have Russian characters in the name and when I paste the folder name
into strPath it again substitutes question marks for each non-ANSI character.
Is there a way round this?

Could you also tell me how to set the macro so it will recognise folders as
well as files when it is going through the For...Next loop?

Thanks

Simon

"Roger Govier" wrote:

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