Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtain Middle vlaue of text with unknow length Abdul Shakeel[_2_] Excel Worksheet Functions 3 September 5th 09 05:58 PM
Open Excel file get error with file names that have spaces in the Kozmo Setting up and Configuration of Excel 6 October 29th 08 02:51 AM
Excel: if in advance unknow# repeated in row get remark in a cell dilettante Excel Worksheet Functions 0 April 5th 07 01:36 PM
Add totals at end of the report with unknow number of rows with VB SITCFanTN New Users to Excel 3 June 4th 06 08:17 PM
EXCEL97 FILE NAMES TRUNCATED TO THE FIRST LETTER IN THE FILE NAME Geoff Porter New Users to Excel 6 May 25th 06 08:31 PM


All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"