Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, typo: if you use XL2003 or above.
Stefi €˛Stefi€¯ ezt Ć*rta: 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! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the tip.
With this function, I see that it is possible to select an "Arrray" of files. What would i need to do to 1) select an array of files with the Getopenfilename method, then 2) perform a series of operations on each file one-at-a-time? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, I'm at a loss! I tried
filestoopen = Application.GetOpenFilename(MultiSelect:=True) It allowed to select multiple files, but returned only the first selected file name as a string, not an array of file names as it's stated in HELP. Maybe somebody else can explain the reason! Stefi €˛fallowfz€¯ ezt Ć*rta: Thanks for the tip. With this function, I see that it is possible to select an "Arrray" of files. What would i need to do to 1) select an array of files with the Getopenfilename method, then 2) perform a series of operations on each file one-at-a-time? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That's what I ran into as well. Thanks for giving it a shot.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Browse up to file | Excel Programming | |||
can't browse file | Excel Discussion (Misc queries) | |||
File Browse Function (Open dialog box for choosing file) | Excel Programming | |||
File Browse Box | Excel Programming | |||
Browse function | Excel Programming |