我在调试(使用Commondialog类)http://www.vba.cn/a2/list.asp?id=356程序时出错,黑体部分是我修改过的,为什么我在多选时返回的文件名只是返回文件目录,在选择单文件时则会返回其全路径
Sub IntBlkBySelectDwg() On Error GoTo Err_Control
Dim BlkFile As Variant Dim i As Integer Dim InstPnt As Variant Dim BlkRefObj As AcadBlockReference Dim varCancel As Variant BlkFile = getFileBySelect("选择图形", "dwg", "CAD图形文件(*.dwg)|*.dwg|" + "所有文件(*.*)|*.*|") '用信息框返回所选文件的路径 MsgBox BlkFile End Sub
'选定多个文件的函数,使用了CommonDialog类 Public Function getFileBySelect(DialogTitle, DefaultExt, Filter) As Variant Dim dlg As CommonDialog Dim Files As Variant Dim i As Integer
Set dlg = New CommonDialog With dlg .DialogTitle = DialogTitle .DefaultExt = DefaultExt .Filter = Filter .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or dlOFNHideReadOnly dlg.ShowOpen getFileBySelect = .FileName End With
End Function
不知道有哪位仁兄调试过此段代码