ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA - open folder (https://www.excelbanter.com/excel-discussion-misc-queries/136005-vba-open-folder.html)

Jeff

VBA - open folder
 
Hi,

I saw this code in a book - it allows you to choose a directory path.

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a location for the backup"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Canceled"
Else
MsgBox .SelectedItems(1)
End If
End With

Here is the problem - when I choose a directory I cannot see the files in
the directory - is there a way to change the code so that I can see the files?

Thanks for your help



Vergel Adriano

VBA - open folder
 
Jeff,

Replace msoFileDialogFolderPicker with msoFileDialogFilePicker


--
Hope that helps.

Vergel Adriano


"Jeff" wrote:

Hi,

I saw this code in a book - it allows you to choose a directory path.

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a location for the backup"
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Canceled"
Else
MsgBox .SelectedItems(1)
End If
End With

Here is the problem - when I choose a directory I cannot see the files in
the directory - is there a way to change the code so that I can see the files?

Thanks for your help




All times are GMT +1. The time now is 01:51 AM.

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