设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1623|回复: 4
打印 上一主题 下一主题

[Access本身] 请教打开文件对话框指定格式筛选

[复制链接]
跳转到指定楼层
1#
发表于 2010-12-2 16:54:59 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
Function GetFileName(TitleText As String, Filter As String, FilterText As String, ByVal DialogType As Integer, Optional ByVal FilePath) As String
'参数DialogType说明:
'1.“打开”对话框
'2.“另存为”对话框(这个项不好用,所以加了出错处理为 Resume Next)
'3.“文件选取器”对话框
'4.“文件夹选取器”对话框
'例:AA = GetFileName("打开", "*.ini;*.txt", "配置文件", 1)

On Error Resume Next
    Dim dlgOpen As FileDialog
    Set dlgOpen = Application.FileDialog(DialogType)
    With dlgOpen
        .title = TitleText
        .Filters.Clear
        .Filters.ADD FilterText, Filter
        .AllowMultiSelect = False     
        If IsMissing(FilePath) Then
            .InitialFileName = a(10)
        Else
            .InitialFileName = FilePath
        End If
        .Show
    End With
    If dlgOpen.SelectedItems.Count > 0 Then
        GetFileName = dlgOpen.SelectedItems(1)
    Else
        GetFileName = ""
    End If
    Set dlgOpen = Nothing

End Function

'4.“文件夹选取器”对话框
'例:AA = GetFileName("打开", "*.ini;*.txt", "配置文件", 1) 这个格式是放在一起了

怎么改成:  
*.ini
*.txt
*.PDF
这样?

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2010-12-4 00:25:42 | 显示全部楼层


就是实现上图那样,给个示范吧

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-15 23:27 , Processed in 0.111260 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表