473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

CMDialog - File open - Multiple file selection order.

When using CMdialog control to open multiple filenames is there a way to force the order in whch the resulting filenames are returned? I require the filenames to be returned in the order they were picked. ie holding down the control key and clicking on each file. However something appears to sort the returned filenames into another order which I've yet to work out.

This is the code I'm using:
Expand|Select|Wrap|Line Numbers
  1. CMDialog.FileName = ""nothing
  2.     CMDialog.DialogTitle = "Select photo/s..."
  3.     CMDialog.Filter = "jpg|*.jpg"
  4.     CMDialog.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNHideReadOnly
  5.     CMDialog.InitDir = "C:\Documents and Settings\Myuser\My Documents\My Pictures\somefolder"
  6.     CMDialog.MaxFileSize = 32000 
  7.     CMDialog.ShowOpen                   'opens fileopen
  8.     strInputFileName = CMDialog.FileName
strInputFileName returns the filenames in a different order to the order in whcih they were selected.

Any advice most welcomed, thanks Mark
Jul 8 '06 #1
7 9105
PEB
1,418 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. Sub Main()
  2.  
  3.     'Declare a variable as a FileDialog object.
  4.     Dim fd As FileDialog
  5.  
  6.     'Create a FileDialog object as a File Picker dialog box.
  7.     Set fd = Application.FileDialog(msoFileDialogFilePicker)
  8.  
  9.     'Declare a variable to contain the path
  10.     'of each selected item. Even though the path is a String,
  11.     'the variable must be a Variant because For Each...Next
  12.     'routines only work with Variants and Objects.
  13.     Dim vrtSelectedItem As Variant
  14.  
  15.     'Use a With...End With block to reference the FileDialog object.
  16.     With fd
  17.  
  18.         'Use the Show method to display the File Picker dialog box and return the user's action.
  19.         'The user pressed the action button.
  20.         If .Show = -1 Then
  21.  
  22.             'Step through each string in the FileDialogSelectedItems collection.
  23.             For Each vrtSelectedItem In .SelectedItems
  24.  
  25.                 'vrtSelectedItem is a String that contains the path of each selected item.
  26.                 'You can use any file I/O functions that you want to work with this path.
  27.                 'This example simply displays the path in a message box.
  28.                 MsgBox "The path is: " & vrtSelectedItem
  29.  
  30.             Next vrtSelectedItem
  31.         'The user pressed Cancel.
  32.         Else
  33.         End If
  34.     End With
  35.  
  36.     'Set the object variable to Nothing.
  37.     Set fd = Nothing
  38.  
  39. End Sub
Sep 6 '06 #2
PEB
1,418 Expert 1GB
Pardon!
A little explication!

In order to display a file dialog box using the FileDialog object, you must use the Show method. Once a dialog box is displayed, no code will execute until the user dismisses the dialog box. The following example creates and displays a File Picker dialog box and then displays each selected file in a message box.
Sep 6 '06 #3
hi

sory but can you please tell me do i have to declare something else to use Filedialog object

i am not able to create object dim fd as FileDialog coz i dont have FileDialog.

i am sorry i am a begginer please help me
thanks
Nov 2 '06 #4
PEB
1,418 Expert 1GB
No no, just try this code...

It should work with the decl=ared References in Access..


:)
Nov 4 '06 #5
SammyB
807 Expert 512MB
PEB, the original question specified that the files be returned in the order that they were picked. I cannot see anyway to use FileDialog to get the files in order. Try both shift-click and control-click, you will see that they are not in the order that they were selected. I would be ecstatic with any solution that returns the order. I cannot do it even with a custom class wrapper around GetOpenFilename. If you have any suggestions, please reply back. TIA --Sam
Mar 8 '07 #6
DougM
1
Hi,

I realise this is quite an old thread, but has anyone figured out how to do this yet. Its most annoying that the FileDialog does not return the selected items in the same order that they were selected.

Cheers
Doug
Oct 15 '07 #7
SammyB
807 Expert 512MB
Hi,

I realise this is quite an old thread, but has anyone figured out how to do this yet. Its most annoying that the FileDialog does not return the selected items in the same order that they were selected.

Cheers
Doug
This is amazing. I'm bleary-eyed trying to solve this annoyance and you ask the same question. I will soon publish the solution in an Article here, but if you're in a hurry & like challenges, the key is here. I'll post a link here when I complete the module.
Oct 16 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Felix Natter | last post by:
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote" multiple="multiple" size="5"> <option...
2
by: yanivoliver | last post by:
Hey, I'm currently trying to find a way to open a dialog box that will allow me to select more than one file at a time, so if I want to upload select all the files in a directory, I won't have...
3
by: JoNaS | last post by:
As a lot of us might now, the input file (aka browse button) in html does not allow for multiple file selection or for filtering file types. The File Open dialog used in WinForms allow these things...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
1
by: mark2802 | last post by:
Im using the CommonDialog activeX control to select multiple file names. However I would like to be able to control using code the resulting view of the files as you can do in realtime using the view...
5
by: charles | last post by:
I have a question about the file Open dialog box. I would like to be able to make the dialog box bigger by selecting the bottom right-hand corner and dragging/expanding the box. I am told by...
2
by: keclipse2525 | last post by:
I have been working on this for a little while now im using the library <fstream> and <iostream>. The object of my program is to read two separate files that contain different amounts of random...
8
by: Janwillem | last post by:
Is there a way to force the wx.FileDialog to show as default the thumbnails vie in stead of list view? thanks, janwillem
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.