![]() |
Unknow file names
I am looking for a way to open up multiple files.
The files i need to open are in the following directories: C:\Documents and Settings\Owner\My Documents\Work\P123\dat C:\Documents and Settings\Owner\My Documents\Work\P123\txt I want each one to open in excel so they can then be transfered to my spread sheet so I can pull out the useful information. The names of the files are random and always changing also I have no idea how many will be in the folder. Please help!!! I am just learning VBA and have no clue what I am doing. Thanks in advance |
Unknow file names
Dim WB As Workbook
Dim res As Variant Set WB = ActiveWorkbook ChDir "\\Stserver\st server\Debtors" res = Application.GetOpenFilename("Xls Files (*.dat), *.xls") If res = False Then Exit Sub Select ALL the files you want to Open. Corey.... wrote in message oups.com... I am looking for a way to open up multiple files. The files i need to open are in the following directories: C:\Documents and Settings\Owner\My Documents\Work\P123\dat C:\Documents and Settings\Owner\My Documents\Work\P123\txt I want each one to open in excel so they can then be transfered to my spread sheet so I can pull out the useful information. The names of the files are random and always changing also I have no idea how many will be in the folder. Please help!!! I am just learning VBA and have no clue what I am doing. Thanks in advance |
Unknow file names
Changing the Path to suit of course
wrote in message oups.com... I am looking for a way to open up multiple files. The files i need to open are in the following directories: C:\Documents and Settings\Owner\My Documents\Work\P123\dat C:\Documents and Settings\Owner\My Documents\Work\P123\txt I want each one to open in excel so they can then be transfered to my spread sheet so I can pull out the useful information. The names of the files are random and always changing also I have no idea how many will be in the folder. Please help!!! I am just learning VBA and have no clue what I am doing. Thanks in advance |
Unknow file names
Assuming you want all files to open, use the code below.
Otherwise, you can edit the ExtensionList entries for any part of the filename that you know e.g. "*123*.txt,SomeValue*.dat" Not sure how Excel will handle these *.dat files though. Depends on their structure. Private Sub CommandButton1_Click() Dim FileName As String Dim FileExtensions() As String Dim i As Long Const FolderPath As String = "C:\Documents and Settings\Owner\My Documents\Work\P123\" Const ExtensionList As String = "*.txt,*.dat" FileExtensions = Split(ExtensionList, ",") For i = LBound(FileExtensions) To UBound(FileExtensions) FileName = Dir(FolderPath & FileExtension(i)) Do While FileName < "" Workbooks.Open FileName FileName = Dir() Loop Next End Sub NickHK wrote in message oups.com... I am looking for a way to open up multiple files. The files i need to open are in the following directories: C:\Documents and Settings\Owner\My Documents\Work\P123\dat C:\Documents and Settings\Owner\My Documents\Work\P123\txt I want each one to open in excel so they can then be transfered to my spread sheet so I can pull out the useful information. The names of the files are random and always changing also I have no idea how many will be in the folder. Please help!!! I am just learning VBA and have no clue what I am doing. Thanks in advance |
All times are GMT +1. The time now is 06:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com