Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to find all folder and/or files in a specific location

I want to make a macro that reads folder names in a particular path. I am
saving files to path F:\Documents\School- FL\CBT Tracker VB project . If
user inputs year as 2008 a new folder is made at that location and the
workbook is save under the new folder with the teachers. When the user comes
back to the prompt screen I wanted to add a list box that allows them to
select the year, and another one to select the teachers name. How can i do
this?


----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...el.programming
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default How to find all folder and/or files in a specific location

The following macro scans the current path and all sub dirs and looks if
there are any Excel files.
If it finds an Excel files it opens and subsequently closes the file again.
Inbetween you can add your code as needed



Sub BuildCRList()

Dim iRow As Integer
Dim cWorkBookName As String

cWorkBookName = "*" & Application.ActiveWindow.Caption & "*"

With Application.FileSearch ' get name
of all Excel workbooks
.LookIn = Application.ActiveWorkbook.Path ' give root
path
.FileType = msoFileTypeExcelWorkbooks
.SearchSubFolders = True ' scan
subdirectories if true

If .Execute() 0 Then ' start if
Excel files found
For iRow = 1 To .FoundFiles.Count Step 1 ' loop
through all workbooks
If Not (.FoundFiles(iRow) Like cWorkBookName) Then ' don't call
yourself
If (Tabelle3.CB_Check_Run.Value) Then ' only if
summary is wanted
Workbooks.Open FileName:=.FoundFiles(iRow) ', ReadOnly:=True
Else
Workbooks.Open FileName:=.FoundFiles(iRow), ReadOnly:=True
End If

' ... Here your code ...

ActiveWindow.Close SaveChanges:=False
End If
Next iRow
End If
End With
End Sub



"Mr. GetRight" wrote:

I want to make a macro that reads folder names in a particular path. I am
saving files to path F:\Documents\School- FL\CBT Tracker VB project . If
user inputs year as 2008 a new folder is made at that location and the
workbook is save under the new folder with the teachers. When the user comes
back to the prompt screen I wanted to add a list box that allows them to
select the year, and another one to select the teachers name. How can i do
this?


----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...el.programming

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
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
How to find all folder and/or files in a specific location Mr. GetRight Excel Discussion (Misc queries) 0 July 2nd 08 06:51 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven[_2_] Excel Programming 1 January 24th 06 04:23 AM
Copy Files from a folder to new location saybut[_3_] Excel Programming 0 February 10th 04 03:26 PM


All times are GMT +1. The time now is 05:41 AM.

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"