打开文件夹并且选中指定的文件的通用函数
'程序设计:唐细刚 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
不积跬步,无以至千里;不积小流,无以成江海。