|
-
Jun 16th, 2008, 04:20 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [Office 2003] FileDialog Sorting
I am using the code modified from the below to let the user select a file to process.
However in some of these places they need to see the FileDiaglow sorted by Date/Time,
whilst in others they need to see it sorted by Name.
Is there any way to do this in VBA?
Code:
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Use a With...End With block to reference the FileDialog object.
With fd
.AllowMultiSelect = False
.Title = "Select File for Processing"
.InitialFileName = ThisWorkbook.Path & "\*.xls"
.InitialView = msoFileDialogViewDetails
'Use the Show method to display the File Picker dialog box and return
' the user's action.
If .Show = -1 Then 'The user pressed the action button.
debug.print .SelectedItems(1)
Else ' The user pressed Cancel.
MsgBox "Loading of File aborted"
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
Signature Under Construction 
-
Jun 16th, 2008, 07:01 AM
#2
Re: [Office 2003] FileDialog Sorting
i have seen /had code to do this for a common dialog, but not sure if it would work with an excel filedialog
http://www.codeguru.com/forum/showthread.php?t=404040
but, having looked at it again, i am not sure that this will work in vba owing to lack of hwnd
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 18th, 2008, 08:10 AM
#3
Thread Starter
Hyperactive Member
Re: [Office 2003] FileDialog Sorting
Thanks westconn.
Looks like it cannot be done, except with a custom built dialog.
Signature Under Construction 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|