can msoFileDialogFolderPicker display file names in the folder

P

Paul C

I am using the following section of code to have a user select a location to
save a newly created file (the name is already determined - newname)

With Application.FileDialog(msoFileDialogFolderPicker)
.Show
newloc = .SelectedItems(1)
End With

ActiveWorkbook.SaveAs Filename:=CStr(newloc) & "\" & newname

Everything works fine, but the FolderPicker only displays folders and no
contents.

While this is not critical, I would like the user to see the folder contents
for reference and it is just bugging me that I can't do this.

I know that changing to FilePicker will do this, but then the user is
picking a name and not using the predetermined newname (which I would
prefer).

Is there a way to have the FolderPicker display the folder content?
or
If using FilePicker how can you force the predetermined name to be used?
 
J

Jacob Skaria

Try the below..Doesnt that odd that the user will have to type or select a
file to get the FilePicker OK button enabled...

Dim strFolder As String
With Application.FileDialog(msoFileDialogFilePicker)
.Show
newloc = .SelectedItems(1)
End With
strFolder = Left(newloc, InStrRev(newloc, "\"))
ActiveWorkbook.SaveAs Filename:=strFolder & newname

If this post helps click Yes
 
J

Jacob Skaria

Set the initial file name to the new name and then Open the dialog

Dim strFolder As String
With Application.FileDialog(msoFileDialogFilePicker)
.InitialFileName = newname
.Show
newloc = .SelectedItems(1)
End With
strFolder = Left(newloc, InStrRev(newloc, "\"))
ActiveWorkbook.SaveAs Filename:=strFolder & newname

If this post helps click Yes
 
P

Paul C

Thanks,

Both ideas look a little better than the blank FolderPicker method, that
just gives me an odd feeling that I was was doing something, but not quite
sure exactly what.

I like the one with the InitialFileName set even though it then does not
show the files within the folder.
 

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