您的位置:首页 > 其它

打开文件夹并且选中指定的文件的通用函数

2007-09-07 18:36 330 查看
'程序设计:唐细刚 2006-4-19 At shenzhen

'函数:OpenFolderAndSelectSpecialFile
'用途:打开指定的文件夹并且选中指定的文件
'参数:szSpecialFileForSelect 想要选中的文件全路径
'返回:True:选中文件成功 False: 选中文件失败或者指定文件不存在
Public Function OpenFolderAndSelectSpecialFile(ByVal szSpecialFileForSelect As String) As Boolean
On Error GoTo hErr
If Dir(szSpecialFileForSelect) <> "" Then
Dim szShellSelect As String
szShellSelect = "Explorer /select, "
szShellSelect = szShellSelect & szSpecialFileForSelect
Shell szShellSelect, vbNormalFocus
OpenFolderAndSelectSpecialFile = True
End If
Exit Function
hErr:
End Function

'调用举例:

Private Sub Command1_Click()
Call OpenFolderAndSelectSpecialFile("C:/Program Files/Internet Explorer/IEXPLORE.EXE")
End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: