ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.GetOpenFilename (https://www.excelbanter.com/excel-programming/437930-application-getopenfilename.html)

John[_140_]

Application.GetOpenFilename
 
I would like Application.GetOpenFilename to prompt me to select a folder,
then open all files in that folder. What is the proper syntax please?



Mike H

Application.GetOpenFilename
 
John

This will open all the .xls files in the selected folder

Sub Open_All_Files()
Application.DisplayAlerts = False
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
MyPath = .SelectedItems(1)
End With
ActiveFile = Dir(MyPath & "*.xls")
Do While ActiveFile < ""
Workbooks.Open Filename:=MyPath & ActiveFile
ActiveFile = Dir()
Loop
Application.DisplayAlerts = True
End Sub

Mike

"John" wrote:

I would like Application.GetOpenFilename to prompt me to select a folder,
then open all files in that folder. What is the proper syntax please?


.


Mike H

Application.GetOpenFilename
 
I forgot to mention that in the folder picker you must 'Double Click' to
select the folder then OK

Mike

"Mike H" wrote:

John

This will open all the .xls files in the selected folder

Sub Open_All_Files()
Application.DisplayAlerts = False
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
MyPath = .SelectedItems(1)
End With
ActiveFile = Dir(MyPath & "*.xls")
Do While ActiveFile < ""
Workbooks.Open Filename:=MyPath & ActiveFile
ActiveFile = Dir()
Loop
Application.DisplayAlerts = True
End Sub

Mike

"John" wrote:

I would like Application.GetOpenFilename to prompt me to select a folder,
then open all files in that folder. What is the proper syntax please?


.



All times are GMT +1. The time now is 04:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com