Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Get names of all workbooks in a directory

I have done this previously but I am unable to remember how I did it.
Basically I have a load of excel workbooks in one directory and I want to
create a loop to get the names of each workbook so that I can store them and
use them all later on. If anyone can help with this one I would be very
gratefull. Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Get names of all workbooks in a directory

One way


Dim oFSO

Sub LoopFolders()

Set oFSO = CreateObject("Scripting.FileSystemObject")

selectFiles "c:\MyTest"

Set oFSO = Nothing

End Sub


'---------------------------------------------------------------------------
Sub selectFiles(sPath)
'---------------------------------------------------------------------------
Dim Folder As Object
Dim Files As Object
Dim file As Object
Dim fldr

Set Folder = oFSO.GetFolder(sPath)

For Each fldr In Folder.Subfolders
selectFiles fldr.Path
Next fldr

For Each file In Folder.Files
If file.Type = "Microsoft Excel Worksheet" Then
Debug.print file.name
End If
Next file

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Graham Whitehead" wrote in message
...
I have done this previously but I am unable to remember how I did it.
Basically I have a load of excel workbooks in one directory and I want to
create a loop to get the names of each workbook so that I can store them
and
use them all later on. If anyone can help with this one I would be very
gratefull. Thanks in advance.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing directory names Norman Jones Excel Programming 1 October 18th 05 12:48 PM
Changing directory names Bob Phillips[_6_] Excel Programming 0 October 18th 05 10:43 AM
Getting file names in a directory John Excel Programming 2 March 8th 05 03:38 PM
Creating a macro that lists directory names within a directory.... Andy Excel Programming 4 November 28th 04 06:13 AM
Aquiring Directory names aking1987[_6_] Excel Programming 1 November 16th 04 01:45 PM


All times are GMT +1. The time now is 05:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"