Optional InclSubFolders As Boolean = True) As VariantĮnumerateFiles_2 = Filter(Split(CreateObject("WScript.Shell").Exec _ Public Function EnumerateFiles_2(sDirectory As String, _ VFiles = EnumerateFiles_2("C:\Users\michal\SkyDrive\csv\bossa\mstcgl_mst\", "xls*") For some reason if you change InclSubFolders to False it only returns the name - got to sort that bit out. This second way goes through the subfolders as well returning path & name. Sub EnumerateFiles(ByVal sDirectory As String, _ This loops through the folder and adds path & name to a collection: Sub Test1()ĮnumerateFiles "C:\Users\michal\SkyDrive\csv\bossa\mstcgl_mst\", "*.xls*", colFiles There's a couple of procedures I use depending on whether I want subfolders as well. Or if U guys know any other method to do this faster just don't hesitate and share Your Code with me - I'll be very grateful. Please, respond to them as well - it's very important 4 me. MsgBox "This code ran successfully in " & total_time & " seconds", vbInformationĪnd two more important questions in the. Total_time = Round(finish - start, 3) ' Calculate total time. ' the name of a file, directory, or an archive that matches a specified pattern.ĭo While xFname "" ' there is already xFname value (1st file name) assigned. ' Dir's job is to return a string representing InitialFolder = "C:\Users\michal\SkyDrive\csv\bossa\mstcgl_mst" ThisWorkbook.Sheets("Lista").Range("D2").Activate This is my portion of code: Option Explicitĭim axRow As Long ' inside the Sheet("Lista") row# This is the folder I want to extract ALL files names from. Select the folder that contains those video files and follow the steps, that should list all files and their properties and you can then discard the columns you do not need. It will be the same one until the end of time, and I want to extract the files names into the Excel column, starting from second row. On the Data Tab, click Get Data - From File - From folder. Remember, you need to use Paste Special, As Text when pasting into some applications.As in the Question: the task is to extract all files names from a folder, but the folder path needs to be hard coded into the macro, to prevent these dialog boxes asking me things and wasting my time.Right click on the row of field names and choose Customize, then reset to reset the view.A new Command Prompt window will open up and from there you can navigate to the folder you want using 'cd' to change directories and 'dir' to list the files/folders. Disable in-cell editing - its easier to select the rows. Go to Start, Run, type 'cmd' without the quotes and click OK.You can paste into any application that accepts paste, however if you paste in Word, you need to use Paste Special, As Text. To open the format columns dialog, right click on the row of field names and choose View Settings, Format Columns Use Format Columns to change the format of the date or number fields. Hold Ctrl as you scroll down or use the PgDown or End key to select the items faster.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |