Just to restate. I copied the code from YOUR email. Cleaned up any wordwrap
problems and Changed the argument to a valid directory for my computer and
ran it. It worked fine for me.
So I can't say what your problem might be.
--
Regards,
Tom Ogilvy
"Don" wrote:
> Tom,
>
> Not sure what's going on here.....I opened a clean wb and inserted the code
> as I posted into a module with sheet1 being the active sheet. Now I'm
> getting an error.
>
> "Ambiguous name detected: fDir"
>
> The line "fDir = FSO............." highlighted in red.
>
> Don
>
>
> "Tom Ogilvy" wrote:
>
> > In contrast, the code ran fine for me. did you look at the activesheet to
> > see the results?
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "Don" wrote:
> >
> > > ooops....forgot to post the code....here it is:
> > >
> > > Sub Finddir()
> > >
> > > Dim FSO As Object
> > > Dim fDir As Object
> > > Dim fSubDir As Object
> > >
> > > Dim i As Long
> > >
> > > Set FSO = CreateObject("Scripting.FileSystemObject")
> > > Set fDir = FSO.GetFolder("C:\Documents and Settings\Brner\My Documents\My
> > > Music\CDG Zips")
> > > For Each fSubDir In fDir.SubFolders
> > > i = i + 1
> > > Cells(i, "A").Value = fSubDir.Name
> > > Next fSubDir
> > >
> > > End Sub
> > >
> > > "Don" wrote:
> > >
> > > > Tom,
> > > >
> > > > Must be something I'm not understanding here....and that's not
> > > > unusual....here's what I tried but it didn't do a thing, didn't give me a
> > > > list or even an error msg. Can you please tell me what I've done wrong here?
> > > >
> > > > As I indicated above in this thread, Jim's add-in worked fine and gave me
> > > > what I wanted but I'd sure like to understand your code also. Any help would
> > > > be greatly appreciated.
> > > >
> > > > Don
> > > >
> > > > "Tom Ogilvy" wrote:
> > > >
> > > > > Sub Finddir()
> > > > > Dim FSO As Object
> > > > > Dim fDir As Object
> > > > > Dim fSubDir As Object
> > > > > Dim i As Long
> > > > > Set FSO = CreateObject("Scripting.FileSystemObject")
> > > > > Set fDir = FSO.GetFolder("C:\MyMainSubFolder")
> > > > > For Each fSubDir In fDir.SubFolders
> > > > > i = i + 1
> > > > > Cells(i, "A").Value = fSubDir.Name
> > > > > Next fSubDir
> > > > > End Sub
> > > > >
> > > > > --
> > > > > Regards,
> > > > > Tom Ogilvy
> > > > >
> > > > > "Don" wrote:
> > > > >
> > > > > > Hi Gang,
> > > > > >
> > > > > > Not sure if this is the correct forum or not but here goes....I would like
> > > > > > to create a list of sub-folder names in either xcel or Word. I don't need to
> > > > > > have the contents of the folders shown, only the names of same. All these
> > > > > > sub-folders are in a seperate main folder on my C: drive. There are over 500
> > > > > > sub-folders involved.
> > > > > >
> > > > > > If I'm in the wrong place, please advise where I might post this....TIA
> > > > > >
> > > > > > Don
> > > > > >
> > > > > >
Bookmarks