Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
File directory structure reorg | Links and Linking in Excel | |||
open file in current directory | Excel Worksheet Functions | |||
open file in current directory | Excel Discussion (Misc queries) | |||
file save error: the file or directory cannot be created | Excel Discussion (Misc queries) | |||
Excel should let me sort the file directory when saving a file | Excel Discussion (Misc queries) |