Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 6062|回复: 6

[分享] 全硬盘高速查找指定文件

[复制链接]
发表于 2011-10-25 15:38 | 显示全部楼层 |阅读模式
本帖最后由 爱疯 于 2012-7-6 13:48 编辑

转自:http://blog.csdn.net/northwolves/archive/2007/04/10/1558718.aspx


  1. Private Declare Function SearchTreeForFile Lib "ImageHlp.dll" (ByVal lpRoot As String, ByVal lpInPath As String, ByVal lpOutPath As String) As Long
  2. Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
  3. Function SearchFile(ByVal Filename As String) As String
  4.     Dim R As Long, i As Long, SearchPath As String
  5.     For i = 0 To 25
  6.     SearchPath = Chr$(i + 65) & ":/"
  7.     If GetDriveType(SearchPath) = 3 Then
  8.         SearchFile = String$(1024, 0)
  9.         R = SearchTreeForFile(SearchPath, Filename, SearchFile)
  10.         If R <> 0 Then SearchFile = Split(SearchFile, Chr(0))(0): Exit Function
  11.         End If
  12.     Next
  13.     SearchFile = "Can't find it is this system"
  14. End Function

  15. Sub macro1()
  16.     Dim F As String
  17.     F = InputBox("Please input a filename to search", "Infomation", "excel.exe")
  18.     MsgBox SearchFile(F)
  19. End Sub  
复制代码

为回答问题在网上搜来的,试下了,真快啊!
真羡慕高手的代码{:011:}
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-3-7 08:48 | 显示全部楼层
回复

使用道具 举报

发表于 2012-3-12 16:10 | 显示全部楼层
回复

使用道具 举报

发表于 2012-5-17 22:22 | 显示全部楼层
有点意思,谢谢!
回复

使用道具 举报

发表于 2012-5-25 05:24 | 显示全部楼层
好东西谢谢分享
回复

使用道具 举报

发表于 2012-9-17 16:43 | 显示全部楼层
好东西谢谢分享

回复

使用道具 举报

发表于 2012-9-25 11:52 | 显示全部楼层
谢谢分享!学习了!
回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-30 01:26 , Processed in 0.343872 second(s), 6 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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