Public Function Xls_OpenFileName() As String -方法名称:Xls_OpenFileName string类型
Dim OF As OpenFilename,Temp As String,rtv As Long,Filter As String -定义变量:of 打开文件名称,trmp string类型,filter string类型
Temp = String$(5120,vbNullChar) -temp 大小不能为空 最大5120K
Filter = "Microsoft Office Excel 文件 (*.xls)" & vbNullChar & "*.xls" & vbNullChar & vbNullChar
With OF -文件名称.xls
.lStructSize = Len(OF) -取长度
.hwndOwner = Application.hWndAccessApp -打开access一个方法
.lpstrFile = Temp -文件名
.nMaxFile = 5120 -文件最大值
.lpstrFilter = Filter -文件名
.lpstrInitialDir = CurrentSelectpass
.nFilterIndex = 1 -页码
.Flags = &H4 -编码
.lpstrTitle = "请指定文件名" -错误提示
End With
rtv = GetOpenFileName(OF)
If rtv Then
Xls_OpenFileName = Left$(OF.lpstrFile,InStr(OF.lpstrFile,vbNullChar) - 1)
' At Once the folder is selected one,it is maintaining.
CurrentSelectpass = Xls_OpenFileName
End If -判断文件是否选中
End Function -结束方法