Guys
With the CmnDialog script as below, when the user selects multiple files, just the filenames are captured ( which is what I need ), but
when a single file is selected, the full path is captured.
Can the lines:
Case 0 ‘if only one was selected we are done
lstFTP.AddItem myFiles(0)
be changed to just capture the fileame?
Many thanks.
Private Sub procAccTrans_Click(Index As Integer)
On Error GoTo cError
Dim i As Integer
Dim myFiles() As String
Dim myPath As String
With CmnDialog1
.MaxFileSize = 32000 ‘this will max out the buffer for the filenames array for large selections. *NEW*
.CancelError = False ‘if cancel is pressed, the code jumps to cError because of the On Error statement above
.Filter = “*.*”
.FilterIndex = 2
.InitDir = “L:MMPDFTransfer”
.Flags = CD_FLAGS ‘this is where we tell it to use multiselect
.ShowOpen
myFiles = Split(.FileName, vbNullChar) ‘the Filename returned is delimeted by a null character because we selected the cdlOFNLongNames flag
Select Case UBound(myFiles)
Case 0 ‘if only one was selected we are done
lstFTP.AddItem myFiles(0)
Case Is > 0 ‘if more than one, we need to loop through it and append the root directory
For i = 1 To UBound(myFiles)
myPath = myFiles(0) & IIf(Right(myFiles(0), 1) “”, “”, “”) & myFiles(i)
lstFTP.AddItem myFiles(i)
Next i
End Select
End With
Exit Sub
cError:
Beep
MsgBox Err.Description ‘*NEW*
End Sub