• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Calculator all file on a link folder

IceFrogBG

Member
Hi all,
I am trying to make a tool to calculator many file (history of machine about product).
I copy some code from Internet and revise for my purpose.
It can be output the result but have some trouble :
+ when calculator MS Excel is not responding (white monitor)
+ I want to add processing bar to my tool but it work not good
Detail as below:
I have a folder include some folder inside, its is called series machine.
Inside each series machine folder have one or more folder called checker.
Inside each checker folder have some folder called model.
Inside each model folder is many file which I have to calculator.
data is saved for everyday, name of each file like that "17-06-23.dat" or "17-06-23.csv"
I want to make tool : only input link of first folder -> can be output result data for each day.
Example : I input link "C:\Users\pcv-2008667\Desktop\LOG TEST" --> Result for each day from 1 to 31.

So I post here for every one can help me.(I don't know how to upload my file to 4room)
Thank all
 

Attachments

Hello.

As per my understand you are looking for all the files to be listed from folders and subfolders...

Call this below function to get the complete list.

Code:
Sub GetFilesInFolder(SourceFolderName As String, Subfolders As Boolean)

'--- For Example:Folder Name= "D:\Folder Name\" and Flag as Yes or No

Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.folder, SubFolder As Scripting.folder
Dim FileItem As Scripting.File
'Dim r As Long
    Set FSO = New Scripting.FileSystemObject
    Set SourceFolder = FSO.GetFolder(SourceFolderName)

    '--- This is for displaying, whereever you want can be configured

    r = 14
    For Each FileItem In SourceFolder.Files
        Cells(r, 2).Formula = r - 13
        Cells(r, 3).Formula = FileItem.Name
        Cells(r, 4).Formula = FileItem.Path
        Cells(r, 5).Formula = FileItem.Size
        Cells(r, 6).Formula = FileItem.Type
        Cells(r, 7).Formula = FileItem.DateLastModified
        Cells(r, 8).Formula = "=HYPERLINK(""" & FileItem.Path & """,""" & "Click Here to Open" & """)"

        r = r + 1  ' next row number
    Next FileItem

    '--- This is the Function to go each and Every Folder and get the Files. This is a Nested-Function Calling.

    If Subfolders = True Then
        For Each SubFolder In SourceFolder.Subfolders
            ListFilesInFolder SubFolder.Path, True
        Next SubFolder
    End If

    Set FileItem = Nothing
    Set SourceFolder = Nothing
    Set FSO = Nothing
End Sub
 
Hello.

As per my understand you are looking for all the files to be listed from folders and subfolders...

Call this below function to get the complete list.

End Sub[/CODE]
Hello Monty.
I am thank you so much for reply my post.
When I run your code it have a error,please see attach picture.
About my purpose :
I have a source folder include many file data, there are more than 2 type of file.
so my idea : + List all sub folder in source folder
+ Check file sub folder
- If it is type 1 -> call sub calculator 1 and make a sheet result
- If it is type 2 -> call sub calculator 2 and make a sheet result
- .....
Finally make sheet result total
 

Attachments

  • error.png
    error.png
    102.9 KB · Views: 2
Back
Top