(as a previous post I have to change code im my project )
My code for the common dialog needs a change.
On single file selection my listbox.additem adds the file with its full path which is how I require it to work now.
On multiple selection the path is stripped away and just the filename added to the list instead.
This was fine before but it now causes an issue with using a different viewing control.
Can anyone help with this so the multiple file selection populates the list with full path and filename?
Code: Select all
Private Sub procDocOther_Click(Index As Integer)
On Error GoTo cError
Dim i As Integer
Dim myFiles() As String
Dim myPath As String
CmnDialog1.FileName = ""
If Me.txtEst = "" Then
MsgBox "Please Enter The Job Number in The Main View", vbInformation, "Document Import"
Exit Sub
End If
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 = "PDF Files|*.pdf"
.FilterIndex = 2
.InitDir = ""
.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
Dim strFile As String
Dim intPos As Integer
' Get filename with path
strFile = myFiles(0)
frmDocImport.Show
frmDocImport.txtPath = CmnDialog1.FileName
frmDocImport.txtDocEst = Me.txtEst
frmDocImport.lstFiles.AddItem strFile
frmDocImport.WebBrowser1.Navigate2 CmnDialog1.FileName
Case Is > 0 'if more than one, we need to loop through it and append the root directory
frmDocImport.Show
frmDocImport.txtPath = CmnDialog1.FileName
frmDocImport.txtDocEst = Me.txtEst
For i = 1 To UBound(myFiles)
frmDocImport.lstFiles.AddItem myFiles(i)
frmDocImport.WebBrowser1.Navigate2 CmnDialog1.FileName
Next i
End Select
CmnDialog1.FileName = ""
End With
Exit Sub
cError:
Beep
MsgBox Err.Description '*NEW*
End Sub