0

所以......我相当肯定我只是错过了一些非常简单的东西,但我没有在网上看到任何东西。我有一个文件对话框,我需要在其中选择多个文件。看起来很简单。我可以使用“oFileDlg.MultiSelectEnabled = True”选择多个文件,但是当我接受发布到列表框中的选定文件时,只显示一个。我相信它正在做的是将文件名连接成一长行,但我不确定如何将它们分开。任何提示或帮助将不胜感激!!!

代码:

Private Sub cmdSourceAdd_Click()
Dim oFileDlg As FileDialog
' Create a new FileDialog object.
Call ThisApplication.CreateFileDialog(oFileDlg)

' Define the filter to select part and assembly files or any file.
oFileDlg.Filter = "Inventor Files (*.iam;*.ipt;*.idw;*.dwg)|*.iam;*.ipt;*.idw;*.dwg|All Files (*.*)|*.*"
' Define the part and assembly files filter to be the default filter.
oFileDlg.FilterIndex = 1
oFileDlg.MultiSelectEnabled = True

' Set the title for the dialog.
oFileDlg.DialogTitle = "Open File Test"

' Set the initial directory that will be displayed in the dialog.
'oFileDlg.InitialDirectory = ThisApplication.FileOptions.ProjectsPath

' Set the flag so an error will be raised if the user clicks the Cancel button.
oFileDlg.CancelError = True

' Show the open dialog.  The same procedure is also used for the Save dialog.
' The commented code can be used for the Save dialog.
On Error Resume Next
oFileDlg.ShowOpen
'    oFileDlg.ShowSave

' If an error was raised, the user clicked cancel, otherwise display the filename.
If Err Then
    MsgBox "User cancelled out of dialog"
ElseIf Not oFileDlg.fileName = "" Then
    lstSource.AddItem oFileDlg.fileName
End If
End Sub
4

1 回答 1

0

向 Jaytek Development 的 Rodney Thomas 寻求解决方案!

ElseIf Not oFileDlg.fileName = "" Then
    Dim fNames As Variant
    fNames = Split(oFileDlg.fileName, "|")
    Dim curName As Variant
    For Each curName In fNames
        lstSource.AddItem curName
    Next curName
End If
于 2014-05-09T14:17:49.393 回答