ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FolderPicker dialog box (https://www.excelbanter.com/excel-programming/308122-folderpicker-dialog-box.html)

MD

FolderPicker dialog box
 
Using the FolderPicker (along with Microsoft Scripting Runtime), how do I
open the dialog box in a specific folder (say c:\temp)

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
' ???? instruction for the dialog box to open in c:\temp
End With

Regards

Michel



Dave Peterson[_3_]

FolderPicker dialog box
 
How about:

Option Explicit
Sub testme01()
Dim fd As FileDialog
Dim curFolder As String
Dim newFolder As String

newFolder = "C:\temp"

curFolder = CurDir

ChDir newFolder
ChDrive newFolder

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
End With

ChDir curFolder
ChDrive curFolder
End Sub

MD wrote:

Using the FolderPicker (along with Microsoft Scripting Runtime), how do I
open the dialog box in a specific folder (say c:\temp)

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
' ???? instruction for the dialog box to open in c:\temp
End With

Regards

Michel


--

Dave Peterson


MD

FolderPicker dialog box
 
This is strange.... I used your exemple... and It worked(only one time) I
modified the value of "newFolder" to D:\temp and it still gave me C:\temp
?? I close the workbook (but kept EXCEL open)... same thing...... I closed
EXCEL all together and it now worked.

It seems that changing the value of newFolder is tricky. Say you want to
add "IF" this then newfolder X value "IF" that then newfolderYvalue

Option Explicit
Sub testme01()
Dim fd As FileDialog
Dim curFolder As String
Dim newFolder As String

newFolder = "C:\temp"

curFolder = CurDir

ChDir newFolder
ChDrive newFolder

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
End With

ChDir curFolder
ChDrive curFolder
End Sub...????


"Dave Peterson" a écrit dans le message de
...
How about:

Option Explicit
Sub testme01()
Dim fd As FileDialog
Dim curFolder As String
Dim newFolder As String

newFolder = "C:\temp"

curFolder = CurDir

ChDir newFolder
ChDrive newFolder

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
End With

ChDir curFolder
ChDrive curFolder
End Sub

MD wrote:

Using the FolderPicker (along with Microsoft Scripting Runtime), how do

I
open the dialog box in a specific folder (say c:\temp)

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
' ???? instruction for the dialog box to open in c:\temp
End With

Regards

Michel


--

Dave Peterson




Dave Peterson[_3_]

FolderPicker dialog box
 
It worked ok the ONE time I tested.

But I couldn't get it to change initial folders.

Maybe you could use Jim Rech's BrowseForFolder.zip at:
http://www.bmsltd.ie/MVP/Default.htm


MD wrote:

This is strange.... I used your exemple... and It worked(only one time) I
modified the value of "newFolder" to D:\temp and it still gave me C:\temp
?? I close the workbook (but kept EXCEL open)... same thing...... I closed
EXCEL all together and it now worked.

It seems that changing the value of newFolder is tricky. Say you want to
add "IF" this then newfolder X value "IF" that then newfolderYvalue

Option Explicit
Sub testme01()
Dim fd As FileDialog
Dim curFolder As String
Dim newFolder As String

newFolder = "C:\temp"

curFolder = CurDir

ChDir newFolder
ChDrive newFolder

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
End With

ChDir curFolder
ChDrive curFolder
End Sub...????

"Dave Peterson" a écrit dans le message de
...
How about:

Option Explicit
Sub testme01()
Dim fd As FileDialog
Dim curFolder As String
Dim newFolder As String

newFolder = "C:\temp"

curFolder = CurDir

ChDir newFolder
ChDrive newFolder

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
End With

ChDir curFolder
ChDrive curFolder
End Sub

MD wrote:

Using the FolderPicker (along with Microsoft Scripting Runtime), how do

I
open the dialog box in a specific folder (say c:\temp)

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.Show
' ???? instruction for the dialog box to open in c:\temp
End With

Regards

Michel


--

Dave Peterson


--

Dave Peterson


w0rm

FolderPicker dialog box
 
Try following:

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
fd.InitialFileName = "c:\temp"
With fd
.Show
End With



Jan

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

FolderPicker dialog box
 
In win98/xl2002, I had to use:
fd.InitialFileName = "c:\temp\"

And to keep it from making it the current directory:

Option Explicit
Sub testme01()
Dim fd As FileDialog
Dim curFolder As String
Dim newFolder As String

newFolder = "C:\temp\"

curFolder = CurDir

ChDir newFolder
ChDrive newFolder

Set fd = Application.FileDialog(msoFileDialogFolderPicker)

With fd
.InitialFileName = newFolder
.Show
End With

ChDir curFolder
ChDrive curFolder
End Sub

(Thanks for posting the solution, w0rm.)



"w0rm <" wrote:

Try following:

Set fd = Application.FileDialog(msoFileDialogFolderPicker)
fd.InitialFileName = "c:\temp"
With fd
Show
End With

Jani

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 12:18 AM.

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