473,804 Members | 4,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CMDialog - File open - Multiple file selection order.

3 New Member
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
strInputFileNam e 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 9164
PEB
1,418 Recognized Expert Top Contributor
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 Recognized Expert Top Contributor
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
mady1380
18 New Member
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 Recognized Expert Top Contributor
No no, just try this code...

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


:)
Nov 4 '06 #5
SammyB
807 Recognized Expert Contributor
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 New Member
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 Recognized Expert Contributor
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
7898
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 value='43'>Aisha</option> <option value='40'>Amsterdam</option> <option value='55'>Asmaa</option> <option value='20'>Beau Rivage</option> <option value='48'>Blue Perl</option>
2
2393
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 to have the number of dialog boxes as files in the directory. I was thinking of using a ActiveX control, but I don't want to make the sure download additional components to be able to do this, so is there maybe some sort of Windows ActiveX control...
3
2311
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 and more. I developed a windows user control in VB.NET with a button and File Open Dialog, which allows multiple file selection. I registered the assembly with regasm.exe and call the object from the html page with the object tag: <OBJECT...
3
3658
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" through "Phase 10" (there are 10 Phases I want to sort from) Once the phase has been selected a second combo box would populate.
1
6592
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 menu, ie details, thumbnails, icons etc. I've tried changing the default view in windowsXP for that folder but the resulting view always defaults to thumbnails. I'd also like to be able to control the order of the filenames in the dialog as...
5
5408
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 my colleagues that this is not "standard" but find it hard to believe. Opening a file in MS word for example, the dialog has
2
2354
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 numbers for a total amount of 50 numbers in the output file. The problem that I'm having is that when I get all the numbers from the 2 files and write and append them to the output file now i dont understand how to get the output file which is a c-string...
8
3725
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
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10575
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10076
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7616
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.