Using Application.FileDialog(msoFileDialogFolderPicker)

A

Ayo

I am trying to use Application.FileDialog(msoFileDialogFolderPicker)
to get a folder and run a macro on each file in that folder. I was using
this approach before:
folderspec = Application.InputBox(prompt:="Input Folder Path", Title:="Get
Folder", Type:=2)
but it requires someone to copy and paste the folder path. But I want to
use a different approach where the filedialog opens and you can pick the
folder directly. I know Application.FileDialog(msoFileDialogFolderPicker) is
what is needed but I can figure out what next. This is what I have, and it's
giving me an error

folderspec = Application.FileDialog(msoFileDialogFolderPicker)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.getFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
s = f1.Path
Workbooks.Open Filename:=s, UpdateLinks:=0
Thanks for the help.
 

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