Hi

I'm trying to use an Excel file to archive configs.  So far I have
been able to find the files and input them into sheet1. with the 1st
code.  However the file name entries have the file name's path
attached to the name.  Is there a property option to only put the file
name in column 1?

Second how do I insert a new worksheet for each file name?  With each
file name I'd like to insert the file contents into a seperate sheet.
And in VBA do you do this by calling another subroutine or do you
insert the code into the for loop?

like:
Sub LoadCFGFiles()
...
   For i to .FoundFiles.Count
           ThisEntry = .FoundFiles(i)
           Cells(NextRow, 1).Value = ThisEntry
           LoadCFGSheet(ThisEntry) ' subroutine to load file
           .....
   Next i

or do I insert the code for inserting the sheet within the for loop?

Thanks for your help.

Mike



Sub LoadCFGFiles()
    'This macro lists all .dns files
    ' in a certain directory to a column in Excel
    ' clear out all cells in Sheet

    Cells.Clear

    ' Add Headings
    Range("A1:B1").Value = Array("FileName", "Path")
    NextRow = 2

    ' Use the FileSearch Object
    With Application.FileSearch
        .NewSearch
        .LookIn = "D:\work\CFG\bkup\5-11\"
        .SearchSubFolders = False
        .Filename = "*.cfg"
        .Execute

        FilesToProcess = .FoundFiles.Count
        ' loop through each confg file in the directory
        For i = 1 To .FoundFiles.Count
            ThisEntry = .FoundFiles(i)
            Cells(NextRow, 1).Value = ThisEntry
            ' Find to path portion.  Start looking from the end
            ' of ThisEntry for a backlash
            NextRow = NextRow + 1
        Next i
    End With

--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---

Reply via email to