Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 126
Default Directory and File Detection

Hi

Can I have help on this please?

I set up files 'Hours' and 'Rate' under each directories 'Jan' to 'Dec'
under directory Lee. I do not want him(Lee) to add a 13th directory under
Lee.

If he does create a 3rd file or 13th directory how can I spot it through VBA
codes?

Thank You.

M Varnendra
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Directory and File Detection


Folder = "c:\temp\"
Count = 0
FName = dir(Folder & "*.*")
Do while FName < ""
Count = Count + 1
FName = dir()
loop

"Varne" wrote:

Hi

Can I have help on this please?

I set up files 'Hours' and 'Rate' under each directories 'Jan' to 'Dec'
under directory Lee. I do not want him(Lee) to add a 13th directory under
Lee.

If he does create a 3rd file or 13th directory how can I spot it through VBA
codes?

Thank You.

M Varnendra

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 126
Default Directory and File Detection

Hi

Can someone complete what Joes says or provide me with new codes please?

Thanks.

"Joel" wrote:


Folder = "c:\temp\"
Count = 0
FName = dir(Folder & "*.*")
Do while FName < ""
Count = Count + 1
FName = dir()
loop

"Varne" wrote:

Hi

Can I have help on this please?

I set up files 'Hours' and 'Rate' under each directories 'Jan' to 'Dec'
under directory Lee. I do not want him(Lee) to add a 13th directory under
Lee.

If he does create a 3rd file or 13th directory how can I spot it through VBA
codes?

Thank You.

M Varnendra

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Directory and File Detection

try this code

Sub Macro1()

Set fso = CreateObject _
("Scripting.FileSystemObject")

LeeFolder = "c:\temp"

Set Folder = _
fso.GetFolder(LeeFolder)

If Folder.subfolders.Count 0 Then
For Each sf In Folder.subfolders

'check if Folder Name is a month
FoundMonth = False
For MonthNum = 1 To 12
MonthNm = MonthName(MonthNum, abbreviate:=True)
If UCase(MonthNm) = UCase(sf.Name) Then
FoundMonth = True
Exit For
End If
Next MonthNum
If FoundMonth = False Then
MsgBox ("Folder " & sf.Path & " is not a month")
Else
FName = UCase(Dir(sf.Path & "\*.*"))
If FName < "HOURS" And _
FName < "RATE" Then

MsgBox ("Extra File : " & sf.Path & "\" & FName)
End If
End If

Next sf
End If

End Sub


"Varne" wrote:

Hi

Can someone complete what Joes says or provide me with new codes please?

Thanks.

"Joel" wrote:


Folder = "c:\temp\"
Count = 0
FName = dir(Folder & "*.*")
Do while FName < ""
Count = Count + 1
FName = dir()
loop

"Varne" wrote:

Hi

Can I have help on this please?

I set up files 'Hours' and 'Rate' under each directories 'Jan' to 'Dec'
under directory Lee. I do not want him(Lee) to add a 13th directory under
Lee.

If he does create a 3rd file or 13th directory how can I spot it through VBA
codes?

Thank You.

M Varnendra

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
File directory structure reorg strebor44 Links and Linking in Excel 1 July 2nd 08 08:50 AM
open file in current directory Tomo Excel Worksheet Functions 1 January 12th 08 12:04 AM
open file in current directory Tomo Excel Discussion (Misc queries) 1 January 11th 08 11:48 PM
file save error: the file or directory cannot be created dublg Excel Discussion (Misc queries) 1 September 25th 06 07:07 PM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM


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