Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
someone had given me this code... (see below)...but the "filesearch" option
does not pop up when I start typing the code.. I am using 2007 version...will that make a difference? Thank you Here is another method Sub test() folder = "c:\temp" Set FS = Application.FileSearch With FS .NewSearch .LookIn = folder .SearchSubFolders = False '.Filename = "Run" '.MatchTextExactly = True .FileType = msoFileTypeExcelWorkbooks FileCount = .Execute If FileCount 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." Else MsgBox "There were no files found." End If End With End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Look in the vba help index for DIR
-- Don Guillett Microsoft MVP Excel SalesAid Software "dstiefe" wrote in message ... someone had given me this code... (see below)...but the "filesearch" option does not pop up when I start typing the code.. I am using 2007 version...will that make a difference? Thank you Here is another method Sub test() folder = "c:\temp" Set FS = Application.FileSearch With FS .NewSearch .LookIn = folder .SearchSubFolders = False '.Filename = "Run" '.MatchTextExactly = True .FileType = msoFileTypeExcelWorkbooks FileCount = .Execute If FileCount 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." Else MsgBox "There were no files found." End If End With End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have you tried the DIR option i posted///
-- If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: someone had given me this code... (see below)...but the "filesearch" option does not pop up when I start typing the code.. I am using 2007 version...will that make a difference? Thank you Here is another method Sub test() folder = "c:\temp" Set FS = Application.FileSearch With FS .NewSearch .LookIn = folder .SearchSubFolders = False '.Filename = "Run" '.MatchTextExactly = True .FileType = msoFileTypeExcelWorkbooks FileCount = .Execute If FileCount 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." Else MsgBox "There were no files found." End If End With End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
it didn't work...
"Jacob Skaria" wrote: Have you tried the DIR option i posted/// -- If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: someone had given me this code... (see below)...but the "filesearch" option does not pop up when I start typing the code.. I am using 2007 version...will that make a difference? Thank you Here is another method Sub test() folder = "c:\temp" Set FS = Application.FileSearch With FS .NewSearch .LookIn = folder .SearchSubFolders = False '.Filename = "Run" '.MatchTextExactly = True .FileType = msoFileTypeExcelWorkbooks FileCount = .Execute If FileCount 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." Else MsgBox "There were no files found." End If End With End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Note the slash after the folder name
strFolder = "c:\temp\" If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: it didn't work... "Jacob Skaria" wrote: Have you tried the DIR option i posted/// -- If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: someone had given me this code... (see below)...but the "filesearch" option does not pop up when I start typing the code.. I am using 2007 version...will that make a difference? Thank you Here is another method Sub test() folder = "c:\temp" Set FS = Application.FileSearch With FS .NewSearch .LookIn = folder .SearchSubFolders = False '.Filename = "Run" '.MatchTextExactly = True .FileType = msoFileTypeExcelWorkbooks FileCount = .Execute If FileCount 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." Else MsgBox "There were no files found." End If End With End Sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
that worked..
how would i loop through the xls files in the folder and open them? Thank you1!! "Jacob Skaria" wrote: Note the slash after the folder name strFolder = "c:\temp\" If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: it didn't work... "Jacob Skaria" wrote: Have you tried the DIR option i posted/// -- If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: someone had given me this code... (see below)...but the "filesearch" option does not pop up when I start typing the code.. I am using 2007 version...will that make a difference? Thank you Here is another method Sub test() folder = "c:\temp" Set FS = Application.FileSearch With FS .NewSearch .LookIn = folder .SearchSubFolders = False '.Filename = "Run" '.MatchTextExactly = True .FileType = msoFileTypeExcelWorkbooks FileCount = .Execute If FileCount 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." Else MsgBox "There were no files found." End If End With End Sub |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the below and feedback
Sub Macro() Dim strFolder As String, strFile As String Dim intCount As Integer strFolder = "d:\" strFile = Dir(strFolder & "*.xls", vbNormal) Do While strFile < "" Workbooks.Open strFolder & strFile intCount = intCount + 1 strFile = Dir Loop MsgBox intCount & " files found" End Sub If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: that worked.. how would i loop through the xls files in the folder and open them? Thank you1!! "Jacob Skaria" wrote: Note the slash after the folder name strFolder = "c:\temp\" If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: it didn't work... "Jacob Skaria" wrote: Have you tried the DIR option i posted/// -- If this post helps click Yes --------------- Jacob Skaria "dstiefe" wrote: someone had given me this code... (see below)...but the "filesearch" option does not pop up when I start typing the code.. I am using 2007 version...will that make a difference? Thank you Here is another method Sub test() folder = "c:\temp" Set FS = Application.FileSearch With FS .NewSearch .LookIn = folder .SearchSubFolders = False '.Filename = "Run" '.MatchTextExactly = True .FileType = msoFileTypeExcelWorkbooks FileCount = .Execute If FileCount 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." Else MsgBox "There were no files found." End If End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
counting excel files in a folder | Excel Programming | |||
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? | Excel Discussion (Misc queries) | |||
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? | Excel Programming | |||
Counting files in a folder | Excel Programming | |||
counting files in a folder | Excel Programming |