Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Quick Q files in a dir

Can anyone suggest a snipit of code to see how many files
are in a dir called, the dir would be a variable called
foldername.

Many thanks in advance




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Quick Q files in a dir

Try this Neil

Sub test()
Dim foldername As String
foldername = "C:\Data"
With Application.FileSearch
.NewSearch
.LookIn = foldername
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
MsgBox .FoundFiles.Count & " Excel files were found"
Else
MsgBox "There were no files found."
End If
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Neil" wrote in message ...
Can anyone suggest a snipit of code to see how many files
are in a dir called, the dir would be a variable called
foldername.

Many thanks in advance






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Quick Q files in a dir

Thanks Ron,
Whats the msoFileType equivalent of *.*, i.e. all files ?


-----Original Message-----
Try this Neil

Sub test()
Dim foldername As String
foldername = "C:\Data"
With Application.FileSearch
.NewSearch
.LookIn = foldername
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
MsgBox .FoundFiles.Count & " Excel files

were found"
Else
MsgBox "There were no files found."
End If
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Neil" wrote in message

...
Can anyone suggest a snipit of code to see how many

files
are in a dir called, the dir would be a variable called
foldername.

Many thanks in advance






.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Quick Q files in a dir

Whats the msoFileType equivalent of *.*, i.e. all files ?
msoFileTypeAllFiles


From the VBA help

MsoFileType can be one of these MsoFileType constants.

msoFileTypeAllFiles
msoFileTypeBinders
msoFileTypeCalendarItem
msoFileTypeContactItem
msoFileTypeCustom
msoFileTypeDatabases
msoFileTypeDataConnectionFiles
msoFileTypeDesignerFiles
msoFileTypeDocumentImagingFiles
msoFileTypeExcelWorkbooks
msoFileTypeJournalItem
msoFileTypeMailItem
msoFileTypeNoteItem
msoFileTypeOfficeFiles
msoFileTypeOutlookItems
msoFileTypePhotoDrawFiles
msoFileTypePowerPointPresentations
msoFileTypeProjectFiles
msoFileTypePublisherFiles
msoFileTypeTaskItem
msoFileTypeTemplates
msoFileTypeVisioFiles
msoFileTypeWebPages
msoFileTypeWordDocuments


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"neil" wrote in message ...
Thanks Ron,
Whats the msoFileType equivalent of *.*, i.e. all files ?


-----Original Message-----
Try this Neil

Sub test()
Dim foldername As String
foldername = "C:\Data"
With Application.FileSearch
.NewSearch
.LookIn = foldername
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
MsgBox .FoundFiles.Count & " Excel files

were found"
Else
MsgBox "There were no files found."
End If
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Neil" wrote in message

...
Can anyone suggest a snipit of code to see how many

files
are in a dir called, the dir would be a variable called
foldername.

Many 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
Quick way(s) to view opened files Jorge Cervantes New Users to Excel 1 June 5th 09 11:12 PM
just a quick one chris Excel Discussion (Misc queries) 1 June 11th 08 12:48 PM
I NEED HELP QUICK Jennifer Excel Discussion (Misc queries) 6 October 1st 07 04:43 PM
HELP QUICK I NEED TO KNOW HOW TO ... Kai Jam via OfficeKB.com Excel Discussion (Misc queries) 2 June 8th 05 03:16 AM
NEED HELP QUICK AGAIN! The_ tone Excel Discussion (Misc queries) 0 May 10th 05 07:20 PM


All times are GMT +1. The time now is 05:13 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"