Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default counting xls files in a folder

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default counting xls files in a folder

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default counting xls files in a folder

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default counting xls files in a folder

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default counting xls files in a folder

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default counting xls files in a folder

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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default counting xls files in a folder


ok...

how do i skip the xls file that is open

because the spread sheet i am working with is in the folder

and when i run the code it wants to reopen or clsoe the existing file...and
hence stoping my vba code

make sense?
"Jacob Skaria" wrote:

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



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default counting xls files in a folder

Check whether the file is open or not using the function mentioned in the
link and based on that open

http://support.microsoft.com/default.aspx?kbid=138621

If this post helps click Yes
---------------
Jacob Skaria


"dstiefe" wrote:


ok...

how do i skip the xls file that is open

because the spread sheet i am working with is in the folder

and when i run the code it wants to reopen or clsoe the existing file...and
hence stoping my vba code

make sense?
"Jacob Skaria" wrote:

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
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
counting excel files in a folder dstiefe Excel Programming 4 August 13th 09 04:08 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
Counting files in a folder Hawki Excel Programming 7 April 14th 04 05:54 PM
counting files in a folder jefe Excel Programming 2 March 2nd 04 07:36 PM


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