![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Aberdeen, Scotland
Posts: 72
|
I'm trying to write a generic open command in vba which opens all files with a particular file extension in a particular folder.
the best i can come up with so far is: workbooks.opentext filename:= "C:Test" & "*" & ".txt" [etc.] the only bit which doesn't work is the "*" bit. The macro runs but, only opens the "first" file in the folder, not all of them. Anyone got any ideas? Cheers, Dave [ This Message was edited by: Puma on 2002-04-22 03:51 ] [ This Message was edited by: Puma on 2002-04-22 03:51 ] |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi Dave,
Sub OpenTextFiles() Dim Fs, i Set Fs = Application.FileSearch With Fs .LookIn = "C:Test" .Filename = "*.txt" If .Execute Then For i = 1 To .FoundFiles.Count Workbooks.OpenText Filename:=.FoundFiles(i) Next End If End With End Sub Cheers back at yu! Tom |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Aberdeen, Scotland
Posts: 72
|
Cheers!!
worked a treat. Dave |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|