所以......我相当肯定我只是错过了一些非常简单的东西,但我没有在网上看到任何东西。我有一个文件对话框,我需要在其中选择多个文件。看起来很简单。我可以使用" 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
答案 0 :(得分:0)
向Jaytek Development的罗德尼·托马斯致敬寻求解决方案!
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