file dialog multi-select

M

Mark Andrews

Anyone have code to bring up a dialog to select multiple files, without
using the filedialog (looking for a way that doesn't require a reference to
a file that some users may not have)?

Somebody suggested this:
http://www.mvps.org/access/api/api0001.htm

but I don't see how to switch it to allow multiselect

Thanks in advance,
Mark
 
D

Douglas J. Steele

To use that code with Multiselect, you need to ensure that the Flag property
includes ahtOFN_ALLOWMULTISELECT . What's returned will then be a string
structured like

path to folder^name of file 1 ^name of file 2^...^name of file n^^

where ^ is supposed to represent the Null character (Chr(0))

That means that you cannot use the TrimNull function included with the
sample.

Instead, you need to trim off the pair of Nulls at the end:

varFileName = Left(varFileName, InStr(varFileName, Chr(0) & Chr(0)) - 1)

You can then use the Split function to put the selected file names into an
array:

arrFiles = Split(varFileName, Chr(0))

The individual files will be:

For lngLoop = 1 To UBound(arrFiles)
Debug.Print arrFiles(0) & arrFiles(lngLoop)
End If

To be honest, I can't remember whether the path in arrFiles(0) includes a
closing slash. I suspect it doesn't, actually, which means you'll probably
need

For lngLoop = 1 To UBound(arrFiles)
Debug.Print arrFiles(0) & "\" & arrFiles(lngLoop)
End If
 
J

Jon Lewis

You include the OFN_ALLOWMULTISELECT flag.

Using the same syntax as the example:
lngFlags = ahtOFN_FILEMUSTEXIST Or _
ahtOFN_HIDEREADONLY Or ahtOFN_NOCHANGEDIR Or _
ahtOFN_ALLOWMULTISELECT
(Make sure you include
Global Const ahtOFN_ALLOWMULTISELECT = &H200
in your declarations)

HTH






Global Const ahtOFN_ALLOWMULTISELECT = &H200
 

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