Excel macro to open files within a folder

C

Craig

I'm trying to create a macro to open all of the files within a certain
folder. For example, it would open all of the .xls files in
C:\Timesheets. I'm lost on how to do this. I'm able to get a single
file open if I have the file name, but the file names are going to
vary. Also is it possible to only open certain files within a specific
folder based on parameters of the filename (like all files starting
with 07*****.xls)?
 
G

Guest

Graig;
I was given this program open an excel file (see below). The only thing you
have to do is put everything under one directory.

Maperalia

'*********Start Program Open Excel File****************
Sub OpenExcelFile()

directory = ThisWorkbook.path & "\"
filetext = Selection.Value & ".xls"
If filetext = ".xls" Then
MsgBox "Please select a File"
Exit Sub
End If
Workbooks.Open directory & filetext
End Sub
'*********End of Program Open Excel File****************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top