Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Obtain Middle vlaue of text with unknow length | Excel Worksheet Functions | |||
Open Excel file get error with file names that have spaces in the | Setting up and Configuration of Excel | |||
Excel: if in advance unknow# repeated in row get remark in a cell | Excel Worksheet Functions | |||
Add totals at end of the report with unknow number of rows with VB | New Users to Excel | |||
EXCEL97 FILE NAMES TRUNCATED TO THE FIRST LETTER IN THE FILE NAME | New Users to Excel |