473,320 Members | 1,802 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,320 software developers and data experts.

Select from FileDialogfilepicker multiple selection and save in different variables

489 256MB
Here's my code
Expand|Select|Wrap|Line Numbers
  1. Set fd = Application.FileDialog(msoFileDialogFilePicker)
  2. fd.Filters.Add "All Pdf files", "*.pdf"
  3. fd.Filters.Add "All files", "*.*"
  4. fd.InitialFileName = "C:\attachements\"
  5. fd.InitialView = msoFileDialogViewList
  6. fd.AllowMultiSelect = True
  7. filechosen = fd.Show
  8.  If filechosen = -1 Then
  9.     For i = 1 To fd.SelectedItems.Count
  10.         Fname = fd.SelectedItems(i)
  11.     Next i
  12. End If
Because there are multiple selections I would like to save each on in a different variable. Is there a way to have Fname change to Fname with the i subscript added to the end. So the first selection would go into Fname1 and the next Fname2 etc.

Thanks for your help.
Nov 9 '18 #1

✓ answered by PhilOfWalton

Depends on what you want to do with the information.

One way is to create an array FNames()

Then your code becomes
Expand|Select|Wrap|Line Numbers
  1.     For i = 1 To fd.SelectedItems.Count
  2.         Redim Preserve FNames(1, i)
  3.         FNames(i) = fd.SelectedItems(i)
  4.     Next i
  5.  
Another way could be
Expand|Select|Wrap|Line Numbers
  1. FName & Chr$(i) = fd.SelectedItems(i)
  2.  
Then, as I said, what do you want to do with the file names?

Phil

1 1191
PhilOfWalton
1,430 Expert 1GB
Depends on what you want to do with the information.

One way is to create an array FNames()

Then your code becomes
Expand|Select|Wrap|Line Numbers
  1.     For i = 1 To fd.SelectedItems.Count
  2.         Redim Preserve FNames(1, i)
  3.         FNames(i) = fd.SelectedItems(i)
  4.     Next i
  5.  
Another way could be
Expand|Select|Wrap|Line Numbers
  1. FName & Chr$(i) = fd.SelectedItems(i)
  2.  
Then, as I said, what do you want to do with the file names?

Phil
Nov 10 '18 #2

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

Similar topics

3
by: Lori Costache | last post by:
Hi guys, I have a problem with multiple selection I have a list with 8 options in pull-down menu. For each option I have a price. Something like that :Element Price Table 10 Sofa ...
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...
1
by: Eddy Balan | last post by:
Hi. Please help me....... I would like to copy the datagrid contents to clipboard and then to paste it into Excel but I can't make a multiple selection. Eddy
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
2
by: ggk517 | last post by:
I have a script like below: ------------------------------------------------------------------------------------------------------------------------ <html> <head> <title>TEST</title> <script...
1
by: DigitalPrankster | last post by:
I have a form that I am using to generate an email with several user selected fields being part of it. As part of this form, I have a select box which allows the user to select which email...
1
by: shidram | last post by:
Hello sir, I have problem while using javascript with HTML multiple selection tag, I want to write javascript in such a way that if a I change the option by clicking on the radio button on html...
4
by: mmasood | last post by:
I would like to know how i can make a multiple selection check box for e.g. like yahoo in box if you select or deselect the header check box all the below check boxes are checked or unchecked. In...
0
mutanic
by: mutanic | last post by:
Hi everybody, I'm stuck at this issue.. I got no idea how to load query on new form base on my selection from other form. Currently I got this "Select Officer" screen/form asking user to select...
0
shilpa george
by: shilpa george | last post by:
Hi All, I am trying to create a dropdownlist in ASP.Net 1.1 that should contain checkboxes inorder to select multiple values. I got a sample from the following link but the dll's provided in it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.