Private Sub btnFileDlg_Click()
'这里演示的是如何用microsoft office 11.0 object library
'里的fileDialog对象打开文件选择对话框
Dim fileDlg As Office.FileDialog
Dim varFile As Variant
Set fileDlg = Application.FileDialog(msoFileDialogFilePicker)
With fileDlg
.AllowMultiSelect = False '只允许选择一个文件
.Title = "选择一个文件"
.Filters.Clear
.InitialFileName = CurrentProject.Path
.Filters.Add "mdb文件", "*.mdb",1
.Filters.Add "adp文件", "*.adp",1
.Filters.Add "所有文件", "*.*"
If .Show = True Then
For Each varFile In .SelectedItems
Me.txtFilePath = varFile
Next
End If
End With
Set fileDlg = Nothing
End Sub
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |