View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default File Browse Function?

Maybe Getopenfilename method (see Help) helps you, is you use XL2003 or above.
Regards,
Stefi


€˛fallowfz€¯ ezt Ć*rta:

I have a macro which opens *.txt files from one location. The current
version of the macro opens a *.txt file to perform the desired
operations, closes the file, then opens the next *.txt file in the
list. In order for the macro to know which files I want to open, I
have to type in the file names into excel.

I was wondering if there was a way to point to a particular folder and
have the macro work on all of the files contained in that folder
without having to type out the filename in excel?

Excerpt of the code which opens the files is below...

num = Application.InputBox("Enter the total number of files to be
processed.")

Sheets("File list").Select
[a1].Select
For x = 1 To num
n = ActiveCell.Formula


Workbooks.OpenText Filename:=n, Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1),
Array(2, 1), _
Array(3, 1)), TrailingMinusNumbers:=True

Thanks!