不知道你是不是说用api获取 Private Function ShowOpen() As String Dim s() As String Dim s1() As String 'Set the structure size OFName.lStructSize = Len(OFName) 'Set the owner window OFName.hwndOwner = Me.hWnd 'Set the application's instance OFName.hInstance = App.hInstance 'Set the filet OFName.lpstrFilter = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0) 'Create a buffer OFName.lpstrFile = Space$(254) 'Set the maximum number of chars OFName.nMaxFile = 255 'Create a buffer OFName.lpstrFileTitle = Space$(254) 'Set the maximum number of chars OFName.nMaxFileTitle = 255 'Set the initial directory OFName.lpstrInitialDir = "C:\" 'Set the dialog title OFName.lpstrTitle = "选择文件" 'no extra flags OFName.flags = OFN_ALLOWMULTISELECT + OFN_EXPLORER 'Show the 'Open File'-dialog If GetOpenFileName(OFName) Then s() = Split(OFName.lpstrFile, Chr(0))
If UBound(s) = 2 Then ss = InStrRev(s(0), "\") str1 = Mid(s(0), ss + 1) str2 = Left(s(0), ss)
ShowOpen = str2 & "|" & Trim$(str1)
Else
For i = 1 To UBound(s) str1 = str1 + " " + s(i) Next
ShowOpen = s(0) & "|" & Trim$(str1)
End If
Else ShowOpen = "" End If End Function OFName.flags = OFN_ALLOWMULTISELECT + OFN_EXPLORER 是不是可多选就是OFN_ALLOWMULTISELECT 但如果只有这个对话框会非常难看 需要加 OFN_EXPLORER才能显示成正常的类型
Private Function ShowOpen() As String
Dim s() As String
Dim s1() As String
'Set the structure size
OFName.lStructSize = Len(OFName)
'Set the owner window
OFName.hwndOwner = Me.hWnd
'Set the application's instance
OFName.hInstance = App.hInstance
'Set the filet
OFName.lpstrFilter = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
'Create a buffer
OFName.lpstrFile = Space$(254)
'Set the maximum number of chars
OFName.nMaxFile = 255
'Create a buffer
OFName.lpstrFileTitle = Space$(254)
'Set the maximum number of chars
OFName.nMaxFileTitle = 255
'Set the initial directory
OFName.lpstrInitialDir = "C:\"
'Set the dialog title
OFName.lpstrTitle = "选择文件"
'no extra flags
OFName.flags = OFN_ALLOWMULTISELECT + OFN_EXPLORER 'Show the 'Open File'-dialog
If GetOpenFileName(OFName) Then s() = Split(OFName.lpstrFile, Chr(0))
If UBound(s) = 2 Then ss = InStrRev(s(0), "\")
str1 = Mid(s(0), ss + 1)
str2 = Left(s(0), ss)
ShowOpen = str2 & "|" & Trim$(str1)
Else
For i = 1 To UBound(s)
str1 = str1 + " " + s(i)
Next
ShowOpen = s(0) & "|" & Trim$(str1)
End If
Else
ShowOpen = ""
End If
End Function OFName.flags = OFN_ALLOWMULTISELECT + OFN_EXPLORER
是不是可多选就是OFN_ALLOWMULTISELECT 但如果只有这个对话框会非常难看
需要加 OFN_EXPLORER才能显示成正常的类型