As it is it works just fine but the list is populated with the full path and filename, this kind of looks unprofessional.
I've messed about with it, broke it and put it back together :-) but for cosmetic purposes would like the list to show only the filename.
Once selected the file will be copied to the location in routine 2.
The code has the split function within it but I've looked at it too long and starting to see double....
Routine1:
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)
' Get position of last backslash
intPos = InStrRev(strFile, "\")
' Extract part after last backslash, i.e. the filename
strFile = Mid(strFile, intPos + 1)
' Add the filename
frmDocImport.Show
frmDocImport.txtDocEst = Me.txtEst
frmDocImport.lstFiles.AddItem myFiles(0)
Case Is > 0 'if more than one, we need to loop through it and append the root directory
frmDocImport.Show
frmDocImport.txtDocEst = Me.txtEst
For i = 1 To UBound(myFiles)
myPath = myFiles(0) & IIf(Right(myFiles(0), 1) <> "\", "\", "") & myFiles(i)
frmDocImport.lstFiles.AddItem myPath
Next i
End Select
CmnDialog1.FileName = ""
End With
Exit Sub
cError:
Beep
MsgBox Err.Description '*NEW*
End Sub
Code: Select all
Private Sub cmdSaveDoc_Click()
Dim DocPath As String
Dim DocType As String
DocType = InputBox("What Type of Document is This?", "")
DocPath = "L:\MMPDF\ConsoleFiles\" & Me.txtDocEst & "\"
Call cmdNewFolder_Click
If DocType = "" Then
MsgBox "You Must Enter A Document Type", vbInformation, "Document Type"
Exit Sub
Else
If MsgBox("This Document Will Be Saved as " & Me.txtDocEst & "-" & DocType & ".pdf", _
vbYesNo + vbInformation) = vbYes Then
FileCopy Me.lstFiles, DocPath & Me.txtDocEst & "-" & DocType & ".pdf"
Kill Me.lstFiles
Else
End If
End If
Unload Me
Call Form1024Image.cmdList_Click
End Sub