ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File Dialog Folder Picker open to particular folder (https://www.excelbanter.com/excel-programming/447547-file-dialog-folder-picker-open-particular-folder.html)

KeriM

File Dialog Folder Picker open to particular folder
 
I'm currently using "Application.FileDialog(msoFileDialogFolderPicker) .Show" to have the user open a folder. When that dialog pops up, it automatically opens to the last folder that was opened. I'd like it to always open to the same root folder, so the user can select the correct folder from there. Is there a way to specify this? I've tried putting a change directory command before the file dialog code, but that didn't do anything.

Just fyi:

All of my folders are on a network path.

I usually use this to nativate to my network path:
Code:

Sub ChDirNet(szPath As String)
    Dim lReturn As Long
    lReturn = SetCurrentDirectoryA(szPath)
    If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
End Sub
'Use this when I want to change directories in my code:
ChDirNet("my file path")


Ben McClave

File Dialog Folder Picker open to particular folder
 
Keri,

Have you tried this?

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = "C:\Desktop"
.Show
End With


KeriM

Quote:

Originally Posted by Ben McClave (Post 1606980)
Keri,

Have you tried this?

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = "C:\Desktop"
.Show
End With

Thank you! That worked perfectly!


All times are GMT +1. The time now is 05:29 PM.

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