Var
Path:String//指定的目次
SearchRec:
TSearchRec
while
FindNext(SearchRec)=0
do
Slist.Add(SearchRec.Name)
Slist:=
TStringList.Create()
Slist:
TStringList
begin
if
FindFirst(Path,faAnyFile,SearchRec)=0
then
begin
Slist.Add(SearchRec.Name)
end
FindClose(SearchRec)
end
//如许Slist里就记录了所有的文件名(包含路径)
第一步 找到jdk安装目录第二步 进入jdk1.6文件夹
第三步 找到docs文件夹
第四步 打开index.html,根据关键字查看api用法
excel vba调用windows API 快速查找所选择的文件excel选中文件名清单、自动从“a1"文件夹中查找相应的文件。
ShellExecuteA,DataObject,Clipboard,find,SendKeys
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Const SW_SHOW = 5
Sub test()
Selection.Copy
Dim MyData As DataObject
Dim sTemp As String, s As String
Set MyData = New DataObject
MyData.GetFromClipboard
sTemp = MyData.GetText
s = Replace(sTemp, vbCrLf, "")
s = Replace(s, vbTab, "")
MyData.SetText (s)
MyData.PutInClipboard
ShellExecute 0&, "find", Range("a1"), _
vbNullString, vbNullString, SW_SHOW
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys s &"{ENTER}"
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)