|
Sub getFileName()
' 显示一个 Office 打开文件对话框,为当前的雇员记录
' 选择一个文件名.如果用户选择了一个文件,
' 则将它显示到图片控件中
Dim fileName As String
Dim result As Integer
Dim Fds As FileDialog
Set Fds = Application.FileDialog(msoFileDialogFilePicker)
With Fds
.Title = "选择雇员照片"
.Filters.Add "所有文件", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "位图文件", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![照片路径].Visible = True
Me![照片路径].SetFocus
Me![照片路径].Text = fileName
Me![姓氏].SetFocus
Me![照片路径].Visible = False
错误信息.Visible = False
End If
End With
End Sub |
|